Skip to Content
0

calculate the difference of two dates

Dec 20, 2016 at 10:10 AM

46

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Kuldeep Ghosh Dec 20, 2016 at 10:19 AM
0

Try this. See if this works:

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

Share
10 |10000 characters needed characters left characters exceeded
Henning Deschka Dec 20, 2016 at 12:21 PM
0

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?

Share
10 |10000 characters needed characters left characters exceeded
Kuldeep Ghosh Dec 20, 2016 at 12:28 PM
0

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")

Share
10 |10000 characters needed characters left characters exceeded