SmartQueryTools

Calculate Date Difference in Excel Files Online

Calculate the difference between two date or timestamp columns in Excel files directly in your browser. Output in days, months, years, hours, minutes, or seconds — no upload required.

How to calculate Date Difference in Excel files

  1. Drop your file onto the upload area. It is loaded into the in-browser engine and the first 200 rows are shown.
  2. Choose the start date column and the end date column. The tool preselects the first two date or timestamp columns it finds.
  3. Pick a unit: days, months, years, hours, minutes or seconds.
  4. Name the output column (the default is date_diff) and click Calculate Difference. The result is end minus start, added as the last column.
  5. Download the file in the same format you uploaded.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Worked example

A small hotel exports its bookings and wants the number of nights for each stay. One guest is still checked in, so the check-out date is blank.

Input (Excel)

Excel workbook, first sheet (Sheet1)

booking_idroom_typecheck_incheck_out
B-2201double2026-07-032026-07-06
B-2202twin2026-07-282026-08-02
B-2203single2026-08-142026-08-15
B-2204double2026-08-20NULL
B-2205suite2026-12-302027-01-04

Settings

  • Start date column: check_in
  • End date column: check_out
  • Unit: days
  • Output column name: nights

Result

booking_idroom_typecheck_incheck_outnights
B-2201double2026-07-032026-07-063
B-2202twin2026-07-282026-08-025
B-2203single2026-08-142026-08-151
B-2204double2026-08-20NULLNULL
B-2205suite2026-12-302027-01-045

Each value is check_out minus check_in in whole days. Stays that cross a month or year end are counted correctly, as B-2202 and B-2205 show. The open booking has no check-out date, so its result is NULL. Had the unit been months, B-2202 would give 1 and B-2201 would give 0, because months are counted by calendar boundaries crossed.

Working with Excel files

Date cells on the first sheet are read from Excel's stored date value, not the text they show. Whether a cell displays 7/3/26, 3-Jul-2026 or 3 July 2026, it is written as 2026-07-03 before loading, so the column arrives as a DATE and the difference works. Cells that hold a time as well arrive as timestamps, which suits the hours and minutes units. There is no month and day mix-up for real date cells.

Dates typed as text, for example with a leading apostrophe, are not real dates. A column of text like 3-Jul-2026 stays text, and the calculation fails, because only ISO text such as 2026-07-03 converts. Run Parse Dates on it first. A date left in General format is just a number such as 46083, so give it a date format in Excel. Blank cells give blank results. Excel's own DATEDIF counts complete months and years, but this tool counts calendar boundaries. Both are correct, they just answer different questions, so a months result here can be 1 higher than DATEDIF for the same pair. In the downloaded workbook the result column is a number, and the date columns are written as yyyy-mm-dd text.

Frequently Asked Questions

Why do my Excel dates fail to convert?

Real Excel date cells load as dates whatever their display style. A failure usually means the cells hold text that looks like a date, or serial numbers in General format. Run Parse Dates on text dates, or apply a date format in Excel to the serial numbers and upload again.

Does this give the same answer as Excel's DATEDIF?

For days, yes. For months and years it can differ by one. DATEDIF counts complete months or years, while this tool counts month or year boundaries crossed between the two dates.

How are months and years counted?

By calendar boundaries crossed, not by complete periods. 31 January to 1 February is 1 month, and 31 December to 1 January is 1 year. The same rule applies to hours and days: 23:00 to 01:00 the next day is 1 day. For exact elapsed time, use hours or seconds and divide.

What if the end date is earlier than the start date?

The result is negative. The tool always computes end minus start, so 3 July to 1 July gives -2 days. Swap the two columns if you want positive numbers.

Can I calculate age in years from a birth date?

Only roughly. You need a second date column to compare against, and years are counted by year boundaries, so someone born in December shows as a year older from 1 January. For exact ages, compare in days and divide by 365.25, or use the SQL Query tool.

Related Tools