Discover the winners & finalists of the 2022 Dataiku Frontrunner Awards!READ THEIR USE CASES

Compute diff between dates and number of days

Solved!
Ankur5289
Level 3
Compute diff between dates and number of days

Hi , Is there a way to have date column as input and number if days stored in Integer format.

i want to subtract them and have my output stored in a date column. The inc() function will not work because i  have the column name and can be used only for incrementing dates by a number.

Suppose i want to decrement a date by a particular column having bigint , then could you pls guide how to do achieve that ?

0 Kudos
1 Solution
HarizoR
Developer Advocate

Hi,

If all your column's values are positive and you want to decrement from it, you can just multiply it by -1 to achieve the desired output:

inc(date, -1*delta_days, "days")

 

Best,

Harizo

View solution in original post

4 Replies
HarizoR
Developer Advocate

Hi,

You can pass negative values to the inc() function if you need to decrement dates, like this:

Screenshot 2022-02-14 at 17.06.50.png

Hope this helps!

Best,

Harizo

0 Kudos
Ankur5289
Level 3
Author

Thanks @HarizoR  for the response. I am having fixed positive integers, is it possible to decrement dates by positive integers. or do you have any ways to transform a postive number to negative number=?

0 Kudos
HarizoR
Developer Advocate

Hi,

If all your column's values are positive and you want to decrement from it, you can just multiply it by -1 to achieve the desired output:

inc(date, -1*delta_days, "days")

 

Best,

Harizo

Ankur5289
Level 3
Author

Thanks a lot @har

 . it worked.

0 Kudos