I have two cell that have time and date in this format "9/12/2021 10:41:571".
I need help with writing a function that will return the difference of both the timestamp in hours
CodePudding user response:
As long as your date/times are formatted as numbers rather than text, you could subtract them from each other then multiply by 24:
=(A2-A1)*24
CodePudding user response:
If the number of hours does not exceed 24
, you can also use the following formulae:
=HOUR(A3-A2)
=MINUTE(A3-A2)
=SECOND(A3-A2)
=CONCATENATE(B2," hour/s ",C2," minute/s, ",D2," second/s")
Therefore, assuming that your two dates are located in the A2
and A3
cells, the formulae above will calculate the difference between the two returning the hours, minutes and seconds.
Spreadsheet
Reference
HOUR;