Python Forum

Full Version: Convert date integers (ex. 43831) to regular format
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm currently learning Python 3 and I am struggling with converting date integers into another format.
The dates have the format 43831, 43832, etc. 43831 being 01-01-2020.

What line of code I need to use to convert my whole column into, let's say, a date format "dd-mm-yyyy"?


[Image: Capture.png]
Screenshot if the above deson't work: https://ibb.co/rm044MN
I tried things, in vain.

Thank you.
post your code, sample input, expected output, full error traceback as text, using proper BBCode tags.
Don't post images.
See BBcode help for more info.
Are these comming from Excel?
Something like this would be a start...

>>> from datetime import datetime,timedelta
>>> (datetime(1900, 1, 1) + timedelta(days=43831-2)).strftime("%d-%m-%Y")
'01-01-2020'