> > >>> excel_date = 38938.0
> > >>> python_date = datetime.date(1900, 1, 1) + 
> > >>> datetime.timedelta(days=excel_date)
> > >>> python_date
> > datetime.date(2006, 8, 11)
>
> Err, that's the wrong answer, isn't it? Perhaps it shoud be
> datetime.date(1900, 1, 29)?

Actually was about to post same solution and got same results. (BTW
Simon, the OP date is Aug 9th, 2006).  Scratched head and googled for
excel date calculations... found this bug where it treats 1900 as leap
year incorrectly:
http://www.ozgrid.com/Excel/ExcelDateandTimes.htm

Plus it treats 1 jan 1900 as day 1, not 0 so just subtract 2 in the
calc:
>>>python_date = datetime.date(1900, 1, 1) + datetime.timedelta(days=excel_date 
>>>- 2)
>>> python_date
datetime.date(2006, 8, 9)

HTH.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to