I'm reading a date from an Excel cell in Python (using .Value
on the cell)... the result that I get is:
07/06/10 00:00:00
I thought this was a string, and so went about trying to figure out how to convert this to the format I need ("yyyyMMdd", or "20100706" in this example). However, after some playing around I realized that it is not being pulled as a string... Running type() on it returns <type 'time'>
.
I then assumed that it was a Python time object, and tried using strftime
on it to convert it to a string... but that didn't work either. It doesn't recognize the strftime
method on the value.
Any idea on how to parse this properly and get the format I want? What am I doing wrong? (And if this clearly contains a date as well as a time, why is Python automatically considering it a time object?)