openpyxl.utils.datetime module

Manage Excel date weirdness.


Convert from a timestamp string to a datetime object. According to 18.17.4 in the specification the following ISO 8601 formats are supported.

Dates B.1.1 and B.2.1 Times B.1.2 and B.2.2 Datetimes B.1.3 and B.2.3

There is no concept of timedeltas in the specification, but Excel writes them (in strict OOXML mode), so these are also understood.

openpyxl.utils.datetime.from_excel(value, epoch=datetime.datetime(1899, 12, 30, 0, 0), timedelta=False)[source]

Convert Excel serial to Python datetime


Convert a time value to fractions of day


Convert a timedelta value to fractions of a day


Convert from a datetime to a timestamp string.

openpyxl.utils.datetime.to_excel(dt, epoch=datetime.datetime(1899, 12, 30, 0, 0))[source]

Convert Python datetime to Excel serial