I have this list of integers and need to convert it to date using python
.
- 42222 should be 8/6/2015
- 42290 should be 10/13/2015
- 42319 should be 11/11/2015
I get the equal date of the integer when i paste in to excel then format the cell to Date
.
I have this list of integers and need to convert it to date using python
.
I get the equal date of the integer when i paste in to excel then format the cell to Date
.
Excel dates start counting around the year 1900. This will do it:
from datetime import datetime, timedelta
def xldate_to_datetime(xldate):
tempDate = datetime(1900, 1, 1)
deltaDays =timedelta(days=int(xldate)-2)
TheTime = (tempDate + deltaDays )
return TheTime.strftime("%m/%d/%Y")
>>> xldate_to_datetime(42290)
'10/13/2015'