Alteryx Designer Discussions

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

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

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?

Alteryx Certified Partner
Alteryx Certified Partner

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




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:




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.

6 - Meteoroid

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

6 - Meteoroid

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