Discover all of the brand-new features and improvements to existing capabilities in the Dataiku 11.3 updateLET'S GO

Using date variables

Solved!
wjkelly
Level 3
Using date variables

Hi,

I'm wanting to store a date in the project variable list, but can't figure out how to make the variable read as a date in, say, a formula step in a recipe.

I've tried to format the date as "yyyy-MM-dd" with and without quotes, as well as "yyyy-MM-ddT00.00.00.000Z" with and without quotes.

When I do the simple date format without quotes (i.e., just 2022-09-24) the variable UI kicks me the following error message

"Invalid format: Expected ',' or '}' after property value in JSON at position 70"

When I put the simple date in quotes (i.e. "2022-09-24") then the variable UI accepts it, but when I try to use the variable in a formula, it simply resolves the math of the string, in this case to "1989". Here are two views of that - one just calling the variable, another trying to use the variable in a date formula (asDate):

 

Sample 1.jpgSample 2.jpg

 I feel like there must be a way to define the variable as a date, but I can't find that in the documentation. 

Thanks for any assistance!

 

Operating system used: MacOS Monterey v12.4
Operating system used: MacOS Monterey v12.4
0 Kudos
1 Solution
MiguelangelC
Dataiker

Hi,

DSS stores variables as strings. Yet, we can later on parse them to the format we desire.

For example, in this case the 'asDate' formula fails because the format provided in the second argument does not correspond to the fed data. For example. see Capture.PNG attached (where Rdate is 1989)

 

On the other hand, we can also use a 'Parse date' processor to transform the variable into a date, though in this case it is a two step process as the processor acts on columns. See Capture2.PNG

 

 

 

 

 

 

 

 

View solution in original post

0 Kudos
3 Replies
MiguelangelC
Dataiker

Hi,

DSS stores variables as strings. Yet, we can later on parse them to the format we desire.

For example, in this case the 'asDate' formula fails because the format provided in the second argument does not correspond to the fed data. For example. see Capture.PNG attached (where Rdate is 1989)

 

On the other hand, we can also use a 'Parse date' processor to transform the variable into a date, though in this case it is a two step process as the processor acts on columns. See Capture2.PNG

 

 

 

 

 

 

 

 

0 Kudos
FarSideFeb
Level 3

What if the first thing you are doing is running a query, and you won't have your date column/values until after your query runs?

Dataiku will not let you parse the date before running the query. Trying to do this with a variable/app scenario, but coming across this issue.

0 Kudos
wjkelly
Level 3
Author

thanks! This helped. It would be great if there was a way to define a variable as a date, bu managing it through parsing as you described works, so I'll move on.

0 Kudos