I know questions like these get asked all the time, but my specific problem doesn't seem to come up (at least I can't find it).
So my problem is like this. I have a MySQL database which has lots of data in it, with one column being full of dates. When I pull these dates, I automatically store them into a list which works great.
But, I also have to format the dates to calculate with. For instance, if I work on one of the dates I may need to extract just the month number. Having imported datetime, I would have imagined it was simple with strftime, but it wasn't. The problem is that they are stored in a string format (list is called last_shipped).
The dates come into the list according to this format:
((datetime.datetime(2012, 11, 30, 0, 0),),)
So when I try and use strftime I get the error
TypeError: descriptor 'strftime' requires a 'datetime.date' object but received a 'str'
My question is, how do I convert a list full of these to a list of workable datetime objects?
Thanks in advance
EDIT:
I am using MySQLdb. An example of the code I have tried that produces the error above is:
z = datetime.datetime.strftime(gr, '%m')
In this case z is the datetime string I mentioned above.