0

I imported excel data, and the date got changed automatically to 5 digits like '44309'. I am using this code to try to change it on this test date since I know its supposed to equal '4/23/2021'.

print(datetime.utcfromtimestamp(0)+timedelta(44309)).strftime(%Y-%m-%d))

Its giving me '2091-04-25'.

Not sure what im doing wrong.

learnin333
  • 59
  • 1
  • 6
  • 2
    https://stackoverflow.com/questions/31359150/convert-date-from-excel-in-number-format-to-date-format-python – stefan_aus_hannover May 12 '22 at 23:48
  • This happens because you are counting forward 44309 days from [the Unix epoch time](https://en.wikipedia.org/wiki/Unix_time), but Excel reckons dates from the beginning of the 20th century. In the future, please try to [figure out the requirements yourself first](https://meta.stackoverflow.com/questions/261592), for example by [using a search engine](https://duckduckgo.com/?q=python+convert+excel+date). – Karl Knechtel May 12 '22 at 23:51

0 Answers0