← All how-to recipes

How to calculate hours between two date-times

✓ Verified in LibreOffice 25.8.7.3

Elapsed hours across days — support tickets, machine uptime, shipping windows.

The formula

AppFormulaNotes
Excel=(B2-A2)*24A2/B2 are date+time values. Format the result as a Number, not a time.
Google Sheets=(B2-A2)*24Identical.
LibreOffice Calc=(B2-A2)*24Identical.

How it works

Date-times are single numbers (days + day-fraction), so subtracting them handles day boundaries automatically: 9:00 on July 24 to 18:00 on July 25 is 1.375 days × 24 = 33 hours — no midnight special-casing needed, unlike time-only values. Divide by 24 again for days, multiply by 60 for minutes. This is why storing timestamps as real date-times (not separate date and time columns) pays off.

Verified, not just documented

We ran =ROUND((DATE(2026,7,25)+TIME(18,0,0)-(DATE(2026,7,24)+TIME(9,0,0)))*24,1) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 33 — exactly the expected result. Every formula here is confirmed by actually executing it.