datetime - Python convert integer to date -


this question has answer here:

i have list of integers , need convert date using python.

  • 42222 should 8/6/2015
  • 42290 should 10/13/2015
  • 42319 should 11/11/2015

i equal date of integer when i paste in excel format cell date.

excel dates start counting around year 1900. 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' 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -