Martin Paul Eve bio photo

Martin Paul Eve

Professor of Literature, Technology and Publishing at Birkbeck, University of London and Technical Lead of Knowledge Commons at MESH Research, Michigan State University

Email (BBK) Email (MSU) Email (Personal) Books Bluesky Github Stackoverflow KC Works Institutional Repo Hypothes.is ORCID ID  ORCID iD Wikipedia Pictures for Re-Use

Excel stores dates in a very odd way: a serial number of days since 1900.

To convert an Excel datestamp to a Python datetime object, you can use this function:

def date_serial_number(serial_number: int) -> datetime:
    """
    Convert an Excel serial number to a Python datetime object
    :param serial_number: the date serial number
    :return: a datetime object
    """
    # Excel stores dates as "number of days since 1900"
    import datetime as dt

    delta = dt.datetime(1899, 12, 30) + dt.timedelta(days=serial_number)
    return delta

Hope this helps someone.