Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How would I add months to a date using formula?

wonsun
5 - Atom

Hello, 

So I'm having trouble adding different months to a certain date. 

One column is a date, and the other column is when the duration of the offer 

Date                     Offer exp.

2019-05-03          36 month

2018-03-27          12 month

2018-11-22          31 month

 

I'm trying to add an extra column using formula and think I should use a datetimeadd

but I'm having trouble filling in the formula. How should I do this?  Help would be appreciated.  Thanks 

6 REPLIES 6
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @wonsun,

 

You could use a text to columns to split your expiry details and use the DateTimeAdd() function:

 

Jonathan-Sherman_0-1594284538232.png

 

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Regards,

Jonathan

ArtApa
Alteryx
Alteryx

DateTimeAdd (<date/time>, <interval>, "months"Return the given date/time extended by the given duration.  The <interval> specified the amount of time to be added, and <units> the date/time units to add.  The units are years, months, days, hours, minutes, or seconds (only one can be used), and the interval can be either positive or negative.

wwatson
12 - Quasar

wwatson_0-1594287719297.png

wwatson_1-1594287790741.png

 

Regards

 

grazitti_sapna
17 - Castor

Hi @wonsun,

 

Here is another approach using only one formula tool. I hope it helps

             

                      datetimeadd.png

Sapna Gupta
wonsun
5 - Atom

Thank you so much! This helped a lot 🙂

spsanu
5 - Atom

Thanks for this very helpful, Just wondering would it be possible to exclude last month , for example start date is Jan21 and month is 12 then as per this formula it would go till next Jan22, however, I would like to stop at Dec21 only, if I put -1 would that work or need to calculate the days differences as well.

 

Thanks,

Satya

Labels