Mark Mc Mahon wrote: > Hi, > > Maybe there is a better way then this suggestion... > > from datetime import datetime > > date = <some PyTime object> > > day = int(xl.activecell.value.Format("%d")) > month = int(xl.activecell.value.Format("%m")) > year = int(xl.activecell.value.Format("%Y")) > > date_as_datetime = datetime(year, month, day)
Frankly, I can't think of anything better. You might combine PyTime.Format and datetime.strptime, or do some kind of integer combination thing with the three values, but nothing's too compelling. Maybe the OP might be interested in xlrd or PyExcelerator (assuming they handle dates a little better). > PyTime is starting to look like a wart :-) > Is it a hold over from when > datetime didn't exist? Think so; guess Mark's had no incentive to change things, and I imagine it would be non-trivial to rework all the PyTimes into datetimes. Maybe, though a new method might be added? (Sadly, though, I'm in no position to offer, and I don't really have an itch to scratch, either). TJG _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32