Python Forum
Convert date integers (ex. 43831) to regular format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert date integers (ex. 43831) to regular format

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:
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?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Something like this would be a start...

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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert Date to another format lonesoac0 2 367 Mar-17-2022, 11:26 AM
Last Post: DeaD_EyE
  Format SAS DATE Racer_x 0 329 Feb-09-2022, 04:44 PM
Last Post: Racer_x
  How can I compare 2 format of date? korenron 4 498 Dec-21-2021, 12:40 PM
Last Post: korenron
  Date format and past date check function Turtle 5 1,181 Oct-22-2021, 09:45 PM
Last Post: deanhystad
  Print first day of the week as string in date format MyerzzD 2 865 Sep-29-2021, 06:43 AM
Last Post: MyerzzD
  Convert timedelta to specified format Planetary_Assault_Systems 3 1,508 Jun-27-2021, 01:46 PM
Last Post: snippsat
  How to convert dates in odd format to months lokhtar 2 1,191 Apr-17-2021, 11:54 AM
Last Post: lokhtar
  String to Date format SAF 2 1,474 Apr-06-2021, 02:09 PM
Last Post: snippsat
  Convert email addresses to VCF format jehoshua 2 2,789 Mar-06-2021, 12:50 AM
Last Post: jehoshua
  How to add previous date infront of every unique customer id's invoice date ur_enegmatic 1 1,346 Feb-06-2021, 10:48 PM
Last Post: eddywinch82

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020