← All how-to recipes

How to calculate hours between two date-times

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

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

The formula

AppFormulaNotes
Excel (desktop)=(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. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 33 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.