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

Calculating days between 2 dates where one is a constant and not in the data set

Scott_Hamilton
6 - Meteoroid

I’m trying to calculate the number of days between 2 dates. One of the dates is not in my data set and is constant (9/30/18). The other date that’s in my data set. What’s the best way do that?

3 REPLIES 3
CharlieS
17 - Castor
17 - Castor

The DateTimeDiff( function can tell you the difference between two date value in an increment you specify. Here's the syntax:

 

DateTimeDiff(dt1,dt2,u)

 

Where dt1 and dt2 are two datetime values, and u is the units. The date values can be a variable input (as long as it's in the correct format), or static values. If your input dates are in a field called [Date] then you can calculate the difference in days from 2018-09-30 using this formula:

 

DateTimeDiff([Date],"2018-09-30","days")

 

Note that "2018-09-30" is the standard date format that Alteryx uses and is necessary for these date calculations. Let me know if you have any questions.

Scott_Hamilton
6 - Meteoroid

Thanks, that worked. If I then wanted to take that number and divide by 365, how is that done?

Scott_Hamilton
6 - Meteoroid

I figured it out....ToNumber([Days])/365

Labels