Converting Excel time-format (hours since 1.1.1901)

Tim Golden mail at timgolden.me.uk
Fri Dec 7 10:21:10 EST 2007


mensanator at aol.com wrote:
> On Dec 7, 7:20�am, Dirk Hagemann <DirkHagem... at gmail.com> wrote:
>> Hello,
>>
>> From a zone-file of a Microsoft Active Directory integrated DNS server
>> I get the date/time of the dynamic update entries in a format, which
>> is as far as I know the hours since january 1st 1901.

If it *is* then the easiest way is this:

<code>
import datetime
print datetime.date (1901, 1, 1) + datetime.timedelta (hours=3566839)

</code>

But, as someone pointed out, that puts you somewhere in 2300.
Where are you getting the 1901 from (and the hours, for that
matter). If it's based, as AD dates are, for example, from 1601,
then the calc becomes:

<code>
import datetime
print datetime.date (1601, 1, 1) + datetime.timedelta (hours=3566839)

</code>

which looks more realistic. But frankly I'm guessing.

TJG



More information about the Python-list mailing list