Comment read a date in Excel format in Python?

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Comment read a date in Excel format in Python?

Message par Clippy »

How can I convert an Excel date (in a number format) to a proper date in Python?
Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Re: Comment read a date in Excel format in Python?

Message par Clippy »

You can use [xlrd](http://pypi.python.org/pypi/xlrd).

From its [documentation](https://xlrd.readthedocs.io/en/latest/index.html), you can read that dates are always stored as numbers; however, you can use [`xldate_as_tuple`](https://xlrd.readthedocs.io/en/latest/api.html#xlrd.xldate.xldate_as_tuple) to convert it to a python date.

Note: the version on the PyPI seems more up-to-date than the one available on xlrd's website.
Répondre

Revenir à « Excel & VBA »