Converting Excel time-format (hours since 1.1.1901)

Dirk Hagemann DirkHagemann at gmail.com
Fri Dec 7 10:50:29 EST 2007


On 7 Dez., 16:21, Tim Golden <m... at timgolden.me.uk> wrote:
> mensana... 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

(3566839/24)/365 = 407   - YES I did this calculation too and was
surprised. But if you try this out in MS Excel:
 ="01.01.1901"+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0)  (put
3566839 in field A1 and switch the format of the result-fieldby right-
click on it to the
date format "14.3.01 13:30")

and then replace 3566839 by, let's say, "2", Excel calculates the date
01.10.1901 2:00 AM. Try out other values like 5 or 24! So I thought
3566839 represents hours.

Dirk



More information about the Python-list mailing list