We have extended our Early Bird Tickets for Inspire 2023! Discounted pricing goes until February 24th. Save your spot!

Alteryx Designer Discussions

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

How to add/subtract days and months to from another date.

wonka1234
9 - Comet

Hi,

 

I want to incorporate the following logic into a new column

 

If [date] => "13th of the month of the [date] column" then [date] + 3months

 

if [date] < "13th of month of the [date] column" then [date] - 1 month\

 

[date] values look like so:

2021-11-03
2021-11-16

 

So with this said the new column should show:

 

2021-11-03       ->    2021-10-03 (-30 days or 1 month)
2021-11-16      ->    2022-02-16   (+90 days or 3 months)

 

 

Thanks,

Jonathan

2 REPLIES 2
AmalinaH
Alteryx
Alteryx

Hi @wonka1234 , you can utilise a formula like this:

 

AmalinaH_0-1655997375658.png

 

if DateTimeDay([Date])<13 then DateTimeAdd([Date],-1,"months")
else DateTimeAdd([Date],3,"months")
endif

 

Hope that helps!

Luke_C
17 - Castor

Hi @wonka1234 

 

Something like the below formula should work. I would note using days vs months in the datetimeadd function will yield different results based on how the formulas work. It looks like months gets you your expected results. 

Luke_C_0-1655997456225.png

 

 

 

Labels