FreeMyTools

Convert a Unix Timestamp to an Excel Date and Serial Number

Epoch seconds to an Excel serial and back, with the 1900 bug and 1904 Mac offset.

Date system
Read the clock as

Epoch → Excel

Excel serial number

45244.925925926
UTC
Local
Zone

Paste this formula instead

Excel → Epoch

Unix timestamp, seconds

1700000000
Milliseconds
ISO 8601

Reverse formula

Keyboard Shortcuts ?
  • Insert the Current Time N
  • Copy the Serial C
  • Toggle This Guide ?
  • Toggle Dark Mode D
  • Focus Primary Input /
  • Clear or Close Esc

The One Formula, and the Number Inside It

To convert a Unix timestamp to a date in Excel you divide and then add. The Unix timestamp Excel formula everyone copies is =(A1/86400)+25569, and it does two separate jobs that are worth separating in your head. Epoch time is the same thing under another name, so to convert epoch time to a date in Excel you use this identical expression.

  • Divide by 86,400. Epoch time counts seconds; Excel counts days. There are 86,400 seconds in a day, so this rescales the unit.
  • Add 25,569. The two systems start in different centuries. Excel serial 1 is 1 January 1900; epoch second 0 is 1 January 1970. Exactly 25,569 days separate them, so this rebases the origin.

That is the whole conversion. You can sanity-check it without a calculator: put 0 in the formula and you get 25569, and formatting that cell as a date shows 1 January 1970. If your version of the formula fails that test, the constant has been mistyped.

Ten Digits, Thirteen, or Sixteen

Nothing inside the number says which unit it is in, so the only clue is how big it is. Systems that log in milliseconds are common — JavaScript, Java and most JSON APIs — and microsecond values turn up in database exports.

Digit count against unit and the divisor to use
Digits Unit Divisor Example
10 Seconds 86400 1700000000
13 Milliseconds 86400000 1700000000000
16 Microseconds 86400000000 1700000000000000

Getting this wrong is loud rather than subtle. To convert milliseconds to a date in Excel with the seconds divisor throws the result roughly a thousand times too far into the future, well past the year 9999 where Excel gives up entirely. The converter above reports which unit it settled on, and lets you overrule it when a low-magnitude millisecond value looks like seconds.

Why You Get a Number Instead of a Date

The commonest follow-up question is not about the maths at all. The formula returns 45244.925925926 and the cell shows exactly that, which looks like failure and is not.

An Excel date serial number is the date. The whole part counts days, the fraction counts the time of day — 0.5 is midday, 0.75 is six in the evening — and a cell format is the only thing that renders it as calendar text. Select the cell, press Ctrl+1, and pick a date format, or write a custom one such as yyyy-mm-dd hh:mm:ss. The underlying number is untouched, which is why you can still subtract two of them to get an interval in days.

If you want the text rather than a formatted number, wrap it: =TEXT((A1/86400)+25569,"yyyy-mm-dd hh:mm:ss"). That produces a string, so remember it will no longer sort or subtract as a date.

The Leap Day That Never Happened

The Excel 1900 leap year bug is real, deliberate, and permanent. 1900 was not a leap year — century years need to divide by 400, and 1900 does not — but Lotus 1-2-3 thought otherwise, and Excel copied the mistake to keep spreadsheets interchangeable in the 1980s. Microsoft has documented it and will not fix it, because doing so would silently move every date in every workbook ever saved.

The practical shape of it:

  • Serial 59 is 28 February 1900, which is correct.
  • Serial 60 is 29 February 1900, a day that did not exist.
  • Serial 61 is 1 March 1900, correct again — and everything after it is correct.

So the damage is confined to the first sixty days of 1900. Anything derived from a Unix timestamp starts in 1970 and lands far clear of it. It only bites when you push a large negative timestamp through the formula, and the converter warns you when a result strays into that window. It is also why date arithmetic spanning that boundary can be off by one, and why Excel and databases disagree on ancient dates.

The 1904 System, or Why Everything Is Four Years Out

Excel supports a second origin. The Excel 1904 date system for Mac was the default on Macintosh versions for years, chosen precisely to dodge the 1900 problem, and it counts from 1 January 1904 instead. The correct constant becomes 24107.

The gap between the two is 1,462 days: four calendar years plus the leap day of 1904. A workbook set to one system, opened and edited by someone assuming the other, shifts every date by four years and one day — enough to look like a data error and not enough to look like a bug.

Check it under File → Options → Advanced → When calculating this workbook. Do not flip the setting to fix a mismatch: it re-interprets the serials already stored rather than converting them, so all your existing dates move. Fix the constant in the formula instead, and set the toggle in the converter above to match the workbook you are pasting into.

Serials Are Naive, and That Is Your Problem to Solve

A Unix timestamp is unambiguous: it counts seconds since a fixed instant in UTC. An Excel serial is not. It records a wall-clock reading with nothing attached — no offset field, no zone name, no daylight-saving flag. Excel will never ask which one you meant, and never warn you that two columns disagree.

That leaves a decision to make before you paste anything into a sheet. Storing UTC keeps the column consistent for anyone who later exports it, and is the right default for logs and audit trails. Storing local wall clock reads naturally for a report that a human will look at once. Either is defensible; mixing them inside one column is not.

The toggle above applies the shift explicitly and shows both readings side by side, along with the zone your browser is in, so you can see what the difference actually is before you commit. Whichever you choose, put it in the column header. Daylight saving means a fixed offset added by hand will be wrong for half the year.

The Power Query Version

A formula in a column is fine for a one-off. For a query that refreshes, the Power Query Unix timestamp conversion is cleaner, because it produces a real datetime rather than a number that needs formatting afterwards:

= #datetime(1970, 1, 1, 0, 0, 0)
    + #duration(0, 0, 0, [Timestamp])

For milliseconds, divide the column by 1000 first. Neither constant appears, which is rather the point — there is no 25569 to mistype and no date system to get wrong, because M works in real datetimes throughout. The result arrives in the sheet already typed as a date.

Before 1970, and Other Edges

Negative timestamps are legal and describe dates before the epoch. They convert with the same formula and produce serials below 25569, which Excel handles happily right down to serial 1. Below that the number goes negative, no date format can render it, and you get hashes or #NUM!.

Two more edges worth knowing. Excel stores about 15 significant digits, so a microsecond timestamp loses sub-second precision on the way through — convert to milliseconds first if that fraction matters. And a timestamp arriving as text rather than a number returns #VALUE!; multiply by 1 or run Text to Columns to coerce it before converting.

Frequently Asked Questions

What formula turns a Unix timestamp into a date in Excel?

For a timestamp in whole seconds sitting in A1, it is =(A1/86400)+25569. Division by 86400 turns seconds into days, and 25569 shifts the origin from 1970 to Excel's own. The cell then holds a serial number, so apply a date format before you judge the answer.

Where does the number 25569 come from?

It is the count of days from Excel's day one, 1 January 1900, up to 1 January 1970 — the two calendars' starting points, measured against each other. Serial 25569 and epoch second zero are the same instant, which is the check the converter above runs first.

My timestamp has 13 digits. What changes?

Thirteen digits means milliseconds, so divide by 86400000 rather than 86400: =(A1/86400000)+25569. Feeding a millisecond value into the seconds formula lands you somewhere around the year 48,000, which Excel refuses to display at all. The unit readout above names what it found before converting.

Why does my cell show 45244.93 rather than a date?

Because that is what the formula returns — a serial number. Excel keeps every date as a number and only a cell format makes it look like a date. Select the cell, press Ctrl+1, and choose a date or a custom format such as yyyy-mm-dd hh:mm:ss. The stored value never changes.

How do I turn an Excel date back into a Unix timestamp?

Reverse the two operations: =(A1-25569)*86400 gives seconds, and multiplying by 86400000 instead gives milliseconds. Wrap it in INT if you want whole seconds, because a formatted date carrying a time of day produces a fractional result.

What is the Excel 1900 leap year bug?

Excel treats 1900 as a leap year, which it was not, and therefore recognises a 29 February 1900 that never existed. The fake day occupies serial 60. Every serial from 61 onwards is consequently correct, and everything below 60 is one day adrift. Since epoch dates start in 1970, converted timestamps are unaffected.

All my dates are four years out. What happened?

The workbook is using the 1904 date system, a Mac Excel default that still travels inside old files. Its origin sits 1462 days later, so the correct constant is 24107 and not 25569. Check File, Options, Advanced, under When calculating this workbook — and switch the converter above to match.

Does an Excel serial number carry a time zone?

No, and that is the trap. A serial is a bare count of days with no offset attached, so 45244.925925 means whatever the reader assumes it means. Decide whether you are storing UTC or local wall clock, convert once, and label the column — the toggle above makes the choice explicit rather than silent.

Can Excel show a timestamp from before 1970?

Yes, down to a point. Negative epoch values produce serials below 25569, which Excel displays normally as long as the result stays above zero — that floor is 1 January 1900. Anything earlier returns a string of hashes or a #NUM! error, because the serial goes negative and no date format can render it.