cancel
Showing results for 
Search instead for 
Did you mean: 

calculate the difference of two dates

former_member318041
Participant
0 Kudos

Hi experts,

I have the following chalange:

There are two given dates: [date-1] and [date-2]. The difference of these two dates has to be calculated like [date-2] - [date-1] and the result needs to be in the following format: dddd HH:mm:ss (days hours:minutes:seconds).

A solution has been created by me, but it uses quite a lot of variables and functions - it is very complicated and not easy to understand!

My question is, if there is an easier way to do this - maybe there is a function that I am not aware of?
Any hint is appreciated!

TIA,
Henning

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member198519
Active Contributor
0 Kudos

Is "234" the days between those two dates? if yes, you can try the below:

=DaysBetween([Date2];[Date1]) + " " + formatdate(Relativedate([Date2];-DaysBetween([Date2];[Date1]));"hh:mm:ss")

former_member318041
Participant
0 Kudos

Seemd as a good idea in the first place, but it unfortunately produces wrong results:

The format in the column "Time Difference" is wrong - I am not looking for a date format, but actually for the number of days, i.e. "234 12:34:56" would be the desired result.

Any more ideas?

former_member198519
Active Contributor
0 Kudos

Try this. See if this works:

=formatdate(Relativedate([Date2];-DaysBetween([Date2];[Date1]));"dd/MM/yyyy hh:mm:ss")