Search code examples
google-sheetsspreadsheetgoogle-docs

Google spreadsheet, comparing durations


I calculated a duration between two times, e.g. between 9:00 am and 11:00 am. So far so good. Now I need to decide if this duration is less 6 hours.

I do remember that this was pain in the s in excel but nevertheless I tried it the simple way:

=IF(E2 < 06:00:00; "y"; "n")

of course that didn't work. Next:

=IF(DURATION(E2) < DURATION(06:00:00); "y"; "n")

still, it didn't work.

So, okay, how can I compare two duration?


Solution

  • Divide hours by 24:

    =IF(E2 < 6/24, "y", "n")

    Value is E2 is a formatted time, actually 1 hour is 1/24, 1 day is 1.

    Some info about date and time formats here:

    http://www.excel-easy.com/examples/date-time-formats.html