Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Endeavoring to extract a more precise number of months and days between dates

Archaeopteryx
10 - Fireball

Hi,

 

I'm attempting to take a duration between two dates and parse that duration out into months and days. 

 

I'm using these formulas, which are nearly precise except when the dates cross July and August. I'm assuming because those two months are 31 days each. 

 

This is [Duration in Months]:

DateTimeDiff([End Date],[Start Date],"months")

 

This is [and days duration]

round(DateTimeDiff([End Date],[Start Date],"days")-([Duration of contract in months]*30.5),1)

 

I rounded up the average number of days in a month from 30.4166666 to 30.5. and am rounding up the whole equation. But when the dates cross over July and August, a day gets dropped. 

 

Is there a more precise method to getting exact days that are the remainder after the number of months have been calculated? 

 

thanks

Chris

10 REPLIES 10
danilang
19 - Altair
19 - Altair

Hi @Archaeopteryx 

 

Use DateTimeToday() as opposed to DateTimeNow().  DateTimeToday returns today's date with no time.  DateTimeNow() returns a DateTime object that includes the current time, so the date calculations are thrown off by 1 day

 

Dan

Labels