ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

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

Formula help: Date of Service... from today

MaryCann
8 - Asteroid

Hi everyone!  New to this formula stuff, and can't look at google SQL examples anymore!    🤤

I'm attempting to add 3 new "From Today" formula columns.  1-Served Within 90 Days; 2-Served 91 to 180 days; 3-Served more than 180 days.  Don't know if I should start with a WHERE clause, an IF clause...  some date clause!  Just UGH.  

Thank you all in advance.  

4 REPLIES 4
Qiu
21 - Polaris
21 - Polaris

@MaryCann 
in MS SQL Server, you can do this

https://stackoverflow.com/questions/17717515/how-to-query-for-todays-date-and-7-days-before-data

In alteryx,

We can use DateTime Function,

DateTimeDiff(Date1, DateTImeToday(), 'Days')

allwynthomas24
11 - Bolide

Hey @MaryCann ,

 

Can you please provide sample data set. Regards.

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @MaryCann,

 

I would use three formulas:

<= 90 Days

 

IF DateTimeDiff(DateTimeToday(),[Date],'days') <= 90
THEN '1'
ELSE '0'
ENDIF

 

 

90 to 180 Days

 

IF DateTimeDiff(DateTimeToday(),[Date],'days') > 90
AND DateTimeDiff(DateTimeToday(),[Date],'days') <= 180
THEN '1'
ELSE '0'
ENDIF

 

 

Over 180 Days

 

IF DateTimeDiff(DateTimeToday(),[Date],'days') > 180
THEN '1'
ELSE '0'
ENDIF

 

 

Kind regards,

Jonathan

MaryCann
8 - Asteroid

Thank you everyone!  @Jonathan-Sherman - worked great!

Labels
Top Solution Authors