Community Conundrum 25: Feature Visualization is now live! Read More

How to add a months to given date

Level 1
How to add a months to given date

Hi Team.

 

Is there a dataprocessor or function to add months to a given date.

Something  like for ex : dateadd function in SQL.

ex 1: for todays date(24-Aug-2020), i would like to add 4 months then it would be 24-Dec-2020

ex2: for todays date(24-Aug-2020), i would like to add - 4 months then it would be 24-Apr-2020.

I know a way that if we use SQL recipe, we can define database functions to get the result,but i am looking some processor or function in datailku

3 Replies
Level 6

@dakakiran 

It is not intuitive how to do this, if you know SQL.

However, you can use a formula step in a visual prepare recipe to make these changes.

You are looking for the inc (increment function) in the Formula.

for example 

inc(LastUpdated, 4, "month")

Will add 4 months to a date in LastUpdated column if that column has been parsed to a DSS standard format with the date parse command.

Increment a Date.jpg

Hope this works for you. 

You can find the documentation on the date formula functions here

https://doc.dataiku.com/dss/latest/advanced/formula.html#date-functions

--Tom
Level 1
Author

Thanks Tom , it worked like a charm.:)

somehow i missed this function

Level 6

@dakakiran ,

Excellent,  so glad I could help.

I also missed the function several times.  

inc is just not very intuitive to me.

--Tom

--Tom
Labels (2)