ThisCalculator

Date and time

Date Calculator Hours: How to Count Time Between Dates

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Date Calculator Hours: How to Count Time Between Dates

This calculator works out the number of hours between two dates and times. You enter a start date and time and an end date and time, and it returns the total elapsed hours, plus the equivalent in days and minutes. The result is exact, accounting for the calendar, so you don’t have to count days or worry about month lengths.

Formula

The calculator converts both dates to a timestamp (milliseconds since a fixed reference point), subtracts the start from the end, and divides by the number of milliseconds in an hour.

Total hours = (End timestamp − Start timestamp) / 3,600,000

  • End timestamp – the date and time you want to measure to, in milliseconds
  • Start timestamp – the date and time you want to measure from, in milliseconds
  • 3,600,000 – milliseconds in one hour (1,000 ms × 60 s × 60 min)

The same logic applies whether you use a spreadsheet, a programming language, or an online tool. Most systems store dates as a number of milliseconds or seconds since a fixed epoch (for example, January 1, 1970). Subtracting two such numbers gives the exact interval, including leap years and month length differences.

Worked Example

Using the defaults: start = January 1, 2024, 09:00; end = January 3, 2024, 17:30.

  1. Convert both to timestamps. For simplicity, assume the epoch is January 1, 1970, 00:00 UTC. The exact epoch doesn’t matter because we only need the difference.
  2. Start: January 1, 2024, 09:00. Days from epoch to Jan 1, 2024 = 19,723 days (including leap years). That’s 19,723 × 86,400,000 ms = 1,704,067,200,000 ms. Add 9 hours = 32,400,000 ms. Start timestamp = 1,704,099,600,000 ms.
  3. End: January 3, 2024, 17:30. Days from epoch to Jan 3, 2024 = 19,725 days. That’s 19,725 × 86,400,000 ms = 1,704,240,000,000 ms. Add 17 hours 30 minutes = 63,000,000 ms. End timestamp = 1,704,303,000,000 ms.
  4. Difference = 1,704,303,000,000 − 1,704,099,600,000 = 203,400,000 ms.
  5. Hours = 203,400,000 / 3,600,000 = 56.5 hours.

The calculator shows 56.50 hours, 2.35 days, and 3,390 minutes. The 0.35 days is the fractional part (0.5 hours / 24 = 0.0208 days, but here 56.5 hours / 24 = 2.3542 days, rounded to 2.35).

When to Use This Calculator

You need this whenever you want the exact number of hours between two moments, not just whole days. Common situations:

  • Calculating billable hours for a project that spans multiple days
  • Figuring out how long a trip or event lasts in hours
  • Checking time remaining until a deadline or launch
  • Converting a duration from days and hours into a single decimal number

The result is a decimal number of hours. For example, 56.5 hours means 56 hours and 30 minutes, because 0.5 of an hour is 30 minutes. If you need a duration in hours and minutes, multiply the fractional part by 60.

How to Read the Result

The main output is the total hours, shown with two decimal places. The other outputs give the same duration in days and minutes for convenience.

  • Total hours – the exact elapsed time in hours, e.g., 56.50
  • Total days – the same duration expressed in days, e.g., 2.35
  • Total minutes – the same duration in whole minutes, e.g., 3,390

If you need to convert to “X days, Y hours, Z minutes,� subtract the whole days from the total, then the whole hours from the remainder. For 56.5 hours: 56.5 / 24 = 2 days with a remainder of 8.5 hours, which is 8 hours and 30 minutes. So 56.5 hours = 2 days, 8 hours, 30 minutes.

Common Mistakes and How to Avoid Them

People often make errors when calculating hours between dates manually. Here are the most frequent ones:

  • Forgetting that dates are inclusive vs. exclusive – If you start at 9 AM on Monday and end at 9 AM on Tuesday, that’s 24 hours, not 48. The calculator subtracts start from end, so it’s always exclusive of the start instant.
  • Mixing AM/PM – Always use 24-hour format or be very careful with AM/PM. 12:00 PM is noon, 12:00 AM is midnight.
  • Ignoring time zones – If you enter times in different time zones, the result will be wrong. Use the same time zone for both, or convert to UTC first.
  • Rounding too early – Round only the final answer, not intermediate steps. For example, 2.35 days is rounded from 2.3542, but if you use 2.35 in further calculations you lose precision.
  • Assuming a day is always 24 hours – In regions with daylight saving time, a day can be 23 or 25 hours. This calculator treats each date as a fixed timestamp, so it correctly handles DST if your input times are in the same time zone and the system adjusts. However, if you’re doing it manually, you must account for DST changes.

Limitations and Edge Cases

This calculator assumes both inputs are valid dates and times. It does not handle:

  • Invalid dates – February 30 or April 31 will produce an error or an unexpected result.
  • End before start – If the end date is earlier than the start, the result will be negative. That’s mathematically correct, but you may want to swap the inputs.
  • Time zone changes – If you enter times in different time zones, the calculator treats them as absolute timestamps. It does not convert between zones. For example, 9:00 in New York and 9:00 in London are not the same moment.
  • Leap seconds – The calculator uses standard milliseconds, which ignore leap seconds. For almost all practical purposes, this is fine.

If you need to account for business hours or exclude weekends, this calculator won’t do that directly. You’d need to subtract non-working periods manually.

Frequently Asked Questions

How do I calculate hours between two dates in Excel?

In Excel, if you have two date-time cells, subtract the earlier from the later and multiply by 24: =(B2-A2)*24. Format the result as a number, not a date. For example, if A2 is 2024-01-01 9:00 and B2 is 2024-01-03 17:30, the formula returns 56.5.

What about daylight saving time?

If your start and end times are in the same time zone and that zone observes DST, the actual number of hours may be 23 or 25 for a day that includes a transition. Most date libraries and spreadsheets handle this automatically if you use date-time objects. Our calculator uses timestamps, so it gives the exact physical time difference, which may differ from the “wall clock� difference.

Can I calculate hours between dates without a calculator?

Yes, but it’s tedious. Convert both dates to a common unit (like days since a fixed date), then to hours, and subtract. You must account for leap years and month lengths. For example, from Jan 1 to Mar 1 in a non-leap year is 59 days, which is 1,416 hours. Adding the time-of-day difference gives the total.

Why does the calculator show 2.35 days for 56.5 hours?

Because 56.5 divided by 24 is 2.354166…, which rounds to 2.35. The decimal represents a fraction of a day, not “2 days and 35 hours.� To get days and hours, multiply the fractional part by 24: 0.3542 × 24 = 8.5 hours, so it’s 2 days, 8 hours, 30 minutes.

What if I only have dates, not times?

If you enter a date without a time, most systems assume midnight (00:00). So from Jan 1 to Jan 3 would be 48 hours (2 days). If you want to include the end day fully, you’d need to set the end time to 23:59 or add one day.

Is there a difference between “hours between� and “hours from date�?

No, they’re the same. “Hours from date� usually means elapsed hours from a start date to now or to a future date. The calculation is identical: subtract the earlier timestamp from the later one and divide by 3,600,000.

Related

Formula used
in start | Start date and time | - | 2024-01-01T09:00 | 0
in end | End date and time | - | 2024-01-03T17:30 | 0
out hours | Total hours | h | (end - start) / 3600000 | 2
out days | Total days | d | (end - start) / 86400000 | 2
out minutes | Total minutes | min | (end - start) / 60000 | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.