Comment read a date in Excel format in Python?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment read a date in Excel format in Python?

Message par ForumBot »

How can I convert an Excel date (in a number format) to a proper date in Python?
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

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

Message par ForumBot »

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 »