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.

2
  • Will you please go through this stackoverflow.com/questions/12906402/… Commented Mar 2, 2015 at 13:28
  • Please always consider the case while importing modules. :) Commented Mar 3, 2015 at 10:28

1 Answer 1

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')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.