<< Click to Display Table of Contents >> TIMEDIFF (time difference) |
Syntax:
TIMEDIFF(StartTime, EndTime)
Description:
This returns the time elapsed between two time values.
A time must be specified for StartTime and EndTime.
You can also specify a date with a time (see last example), but in this case both StartTime and EndTime have to include a date, otherwise a #VALUE! error value is returned.
Note:
Compared to simply subtracting time values, this function has the following advantage when EndTime is smaller than StartTime:
An employee starts his shift, for example, at 10:00 pm and leaves at 6:00 am. If calculating his hours of work by subtracting 10:00 pm from 6:00 am, the result would be -16 hours. If the TIMEDIFF function is used, the correct result (8 hours) is returned.
Example:
TIMEDIFF("8:00 AM", "4:00 PM") returns 8:00
TIMEDIFF("10:00 PM", "6:00 AM") returns 8:00
TIMEDIFF("10/01/2018 10:00 PM", "10/02/2018 6:00 AM") returns 8:00
Compatibility notes:
This function does not exist in Microsoft Excel. If you save a document in Excel format, all calculations using this function will be replaced with their current result as a fixed value.
See also: