Skip to Content

calculate the difference of two dates

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Dec 20, 2016 at 10:19 AM

    Try this. See if this works:

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

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 20, 2016 at 12:21 PM

    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?

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 20, 2016 at 12:28 PM

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

    Add comment
    10|10000 characters needed characters exceeded