Excel dates are off by four years: check the workbook date system first

iso_dates controls how dates are serialized and does not automatically turn in-memory datetime values into strings. Date serial numbers must use the workbook's epoch; here the two date systems are compared, and the saved XML and the values read back are checked.

Key Points of This Article

  • A date offset of about 1462 days usually means the workbook epoch does not match the parsing assumption; read wb.epoch first to confirm.
  • iso_dates only controls how dates are serialized in the file; it does not automatically convert in-memory datetime objects into strings.
  • Datetimes with timezone information must be converted to a unified time zone and have tzinfo stripped before writing, because Excel does not store time zone information.
  • In the 1900 date system, serial number 60 corresponds to the nonexistent date 1900-02-29; it should be flagged as invalid, the original value retained, and left for manual confirmation.

Excel date values drift by four years, and in most cases the cause is the workbook's date system rather than the data itself. This article is for developers and data staff who handle report exports, ETL scripts, or cross-platform Excel file exchange. When you see an overall date shift, numbers that won't display as dates, or anomalies around 1900, work through the checks in the order given here.

After reading this article, you will understand the differences between the 1900 and 1904 date systems, know how to read workbook.epoch to confirm which system the current workbook uses, and master acceptance methods for checking the XML after saving and reading back the values. The code and tables in the article are all illustrated with synthetic samples, making it suitable as a checklist before handling real files.

What to do when Excel dates are off by four years? One-sentence conclusion

First read the workbook workbook.epoch, confirm the date system, and only then perform the conversion; handle boundary dates and time zone issues separately.

Your situationRecommended PracticesCause
The exported dates are shifted by about 1462 days overall.First read workbook.epoch and confirm the workbook's date systemThe 1900 and 1904 systems differ by 1462 days, so if the reading side assumes the wrong one, every serial number will be interpreted incorrectly.
The cell contains a number, but it cannot be displayed as a dateCheck and complete the number_format date format maskWhen the numeric type is correct, a missing format causes display anomalies.
Dates before March 1900 in the data, or 1900-02-29Mark as invalid or refer for manual review, retaining the original serial numberThis date does not exist in the Gregorian calendar, so it should not be forcibly converted.
datetime with time zone needs to be writtenStrip tzinfo after converting to UTCExcel does not support storing time zones; all times are naive local times.
The document needs to be exchanged across platforms.Explicitly declaring the date systemReceiver default settings differ, which may cause silent offset.

Differences Between the 1900 and 1904 Date Systems

Dates in an XLSX file are essentially floating-point serial numbers, and their meaning depends entirely on the date system the workbook is bound to. The XLSX specification allows two base epochs:

  • 1900 date system: Default in Windows; serial number 1 represents 1900-01-01
  • 1904 date system: Default in early Mac systems; serial number 0 represents 1904-01-01

There is a fixed offset of 1462 days between the two systems, which is the main source of the "four-year difference" in dates. In addition, the 1900 date system carries a legacy issue: it wrongly treats 1900 as a leap year, so the non-existent date 1900-02-29 is effectively legitimized in Excel.

Core Comparison

Project1900 date system1904 date system
Serial number starting pointSerial number 1 corresponds to 1900-01-01Serial number 0 corresponds to 1904-01-01
Common default sourcesWindowsEarly Mac
Offset from Another System1462 days apart1462 days apart
Special IssuesThe year 1900 was mistakenly treated as a leap year, so the date 1900-02-29 exists.This issue is not addressed in this article.

Why data from before 1900 requires special care

If you are working with historical data from before March 1900, Python's datetime module cannot directly represent February 29. According to the official openpyxl documentation, to remain compatible with Excel's behavior, the library emulates this anomaly when reading dates in the 1900 date system for January and February, but 1900-02-29 itself cannot be converted into a valid Python datetime object.

For most modern business data, the key is to identify which system the current workbook uses and to state it explicitly when exchanging files across platforms, so that the recipient does not experience silent shifts caused by differing default settings.

Synthetic Example: Boundary Inputs and Handling Methods

To illustrate the issue, we construct a synthetic scenario: a report exported by a financial system uses the 1904 date system, but the downstream ETL script parses dates by default under the 1900 system.

Handling of Erroneous or Boundary Inputs:

  1. If the input serial number is 60 and the workbook uses the 1900 system, it corresponds to the fictitious 1900-02-29 in Excel. Python's native datetime will raise ValueError.
  2. In this case, the conversion should not be forced. Instead, the exception should be caught, and the value should be recorded as the original value or as a special marker, because the date does not exist in the Gregorian calendar.
  3. If a datetime object with timezone information is passed in for writing, openpyxl does not automatically convert the time zone; instead, it requires stripping the tzinfo first, otherwise a write error or exception may occur.
  4. Excel itself does not support time zone storage; all times are naive local times.

Date System Detection and Safe Conversion Code

This example demonstrates how to safely handle date system differences in memory. The code is for logical demonstration only; no actual file reading or writing is performed. It should be run in a dependency environment that you have locked yourself; openpyxl >= 3.1.0 is recommended. The example contains no network requests or file overwrite operations, and all assertions are based on synthetic data.

from datetime import datetime
from io import BytesIO
from zipfile import ZipFile
from openpyxl import Workbook, load_workbook
from openpyxl.utils.datetime import from_excel, CALENDAR_MAC_1904, CALENDAR_WINDOWS_1900
assert from_excel(1, CALENDAR_MAC_1904) == datetime(1904, 1, 2)
assert from_excel(1, CALENDAR_WINDOWS_1900) == datetime(1900, 1, 1)
wb = Workbook()
wb.epoch = CALENDAR_MAC_1904
wb.iso_dates = True
value = datetime(2026, 9, 26, 12, 30)
wb.active["A1"] = value
assert wb.active["A1"].value == value
out = BytesIO()
wb.save(out)
with ZipFile(BytesIO(out.getvalue())) as z:
    xml = z.read("xl/worksheets/sheet1.xml")
    assert b't="d"' in xml and b"2026-09-26T12:30:00" in xml
restored = load_workbook(BytesIO(out.getvalue()))
assert restored.active["A1"].value == value
assert restored.epoch == CALENDAR_MAC_1904

Acceptance Criteria and Boundaries for Manual Review

Observe the phenomenonInput or Boundary ConditionsExpected output or processing decisionIs automation applicable?
All dates shifted by 1462 days uniformlywb.epoch is inconsistent with the parsing assumptionRead wb.epoch, then re-convert the serial numberYes
1900-02-29 appears in the data1900 system and serial number is 60Marked as invalid date, original serial number 60 retainedNo, manual confirmation of the business meaning is required.
Time partially lost or misalignedInput datetime with tzinfoConvert to UTC first, then strip tzinfo before writing.Partial; the target time zone needs to be defined manually
Cells show a number but are formatted as a dateThe numeric type is correct, but number_format is missingCheck and complete the date format maskYes
Historical dates (earlier than 1900-01-01) display incorrectlyDate earlier than 1900-01-01Switch to text-file storage or a dedicated history databaseNo, XLSX is not suitable for this scenario.

Note that the code demonstration only verifies the correctness of the conversion logic; it does not equal end-to-end effectiveness. Real files may mix multiple date formats, conditional formatting, or dates generated by formulas, and all of these require an additional parsing layer. When encountering dates before March 1900, cross-time-zone collaboration data, or non-standard calendars (such as the lunar calendar or fiscal years), the process should be routed to a manual review workflow, and the automated script should not correct them on its own.

🎯 Which Approach Suits You?

If you need to read dates from the exported file

First read workbook.epoch, confirm the date system, then decide whether to re-convert the serial number.

If your data involves dates before March 1900

Mark the records related to 1900-02-29 as invalid, retain the original serial numbers, and hand over to a human for confirmation of their business meaning.

If you need to write timezone-aware times to Excel

First convert everything to UTC, then strip tzinfo; the target time zone must be defined manually.

If you need to exchange files with other systems

Explicitly declare the date system, and verify the read-back date values on the receiving end.

❓ Frequently Asked Questions (FAQ)

1. Why are the exported dates shifted by about four years overall?

The common cause is that the workbook's date system does not match what the reading side assumes. The 1900 and 1904 date systems differ by 1,462 days.

2. Does iso_dates automatically convert datetime to a string?

No. iso_dates only controls how dates are serialized in the file; it does not automatically convert the in-memory datetime to a string.

3. Why can't 1900-02-29 be converted to Python's datetime?

The system incorrectly treats 1900 as a leap year, so 1900-02-29 exists in Excel even though this date does not exist in the Gregorian calendar. In Python, datetime raises ValueError in this case, so the original value or a special marker should be recorded instead.

4. How should a timezone-aware datetime be written to Excel?

Excel does not support storing time zones. Times should first be converted to UTC, and the tzinfo should then be stripped before writing; openpyxl does not perform the time zone conversion automatically.

📝 Summary

Date offset problems usually come from the workbook's date system. Confirm workbook.epoch before doing the conversion, which avoids most silent errors. Boundary dates and time zone issues should be left to manual review.

Try it now: upload a document and start translating right away, with the original layout preserved.

References and Next Steps

  • openpyxl official datetime documentation: https://openpyxl.readthedocs.io/en/stable/datetime.html
  • Microsoft explanation of the 1900 and 1904 date systems: https://docs.microsoft.com/en-us/office/troubleshoot/excel/1900-and-1904-date-system
  • Microsoft explanation of the 1900 leap year bug: https://docs.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year

Next step: choose a de-identified Excel sample that you are authorized to use, run the epoch detection code above, and confirm whether its date system matches your processing logic. If there is a mismatch, adjust the conversion parameters before generating the translated deliverable.

Use This Checklist for Document Translation

Before translating the table, first decide which content is text and which is formulas and business codes. The post-translation check should confirm not only that the Chinese has been converted into the target language, but also that formulas, identifiers, and reference relationships have not been changed.

OmniDoc's document translation supports formats such as PDF, Word, PPT, and Excel. Scanned documents have their text recognized first, tables are translated cell by cell with rows and columns preserved, and PDFs produce two versions: a bilingual side-by-side version and a translation-only version. Paid translation also lets you upload a glossary and enable context-aware translation.

Updated 2026-11-29