0

I am reading data from a excel sheet like this -

day1 = first_sheet.cell(row,26).value

I want to use this date for some other operations later but the data is coming in a float format which i find very confusing and unsuitable for debugging.

I tried using this --->>

day = datetime.datetime(*xlrd.xldate_as_tuple(day1, 0))

But i got this error --->>

AttributeError: type object 'datetime.datetime' has no attribute 'datetime'

I am using python 2.7 Kindly help me out.

EdChum
  • 376,765
  • 198
  • 813
  • 562

1 Answers1

0

You can try this.

day1 = first_sheet.cell(row,26).value
d = xlrd.xldate_as_tuple(int(day1), 0)
#convert date tuple in yy-mm-dd format
d = datetime.datetime(*(d[0:3]))
dStr = d.strftime('%Y-%m-%d')
Ankit Sachdeva
  • 179
  • 1
  • 9