Compute duration in days

From the example in Date and Time Expressions : Examples that compute duration in days, months and years

FLOOR(((HOUR([EndDate] - [StartDate])) - (([Years] * 365.24 * 24.0) + ([Months] * 30.4 * 24.0))) / 24.0)

Question :
What is the difference from :
FLOOR(HOUR([EndDate] - [StartDate])/24)
since i got the same result.

0 2 215
2 REPLIES 2

It seems the expression example from the doc simply returns the difference between the day number.

May 25 2021 and May 20 2021, returns 5 (25-20).
May 25 2021 and April 20 2021, also returns 5 (25-20).
May 25 2021 and April 20 1999, also returns 5 (25-20).

Why would you ever need this expression? Iโ€™m not sure.

I need to compute the number of days between the startdate and the enddate. (how many days between two dates input in apps aka the duration of using a spare part)

At first, I was wrongly using an expression : DAY([EndDate]) - DAY([StartDate]) , returns the difference between the day number. So I searched from the doc, found the expression example there.

Honestly, I didnโ€™t try the long expression from the doc. Confused with the [Years] and [Months] as said to be Virtual Columns there. I try : FLOOR(HOUR([EndDate] - [StartDate])/24) , the outcome is exactly what Iโ€™m looking for. So I wondered is there anything that I should know about that long expression.

Thanks @Marc_Dillon

Top Labels in this Space