Converting Excel time-format (hours since 1.1.1901)

mensanator at aol.com mensanator at aol.com
Fri Dec 7 16:17:07 EST 2007


On Dec 7, 9:59 am, Dirk Hagemann <DirkHagem... at gmail.com> wrote:
> On 7 Dez., 16:50, Dirk Hagemann <DirkHagem... at gmail.com> wrote:
>
>
>
>
>
> > 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
>
> Oh - sorry again: in the Excel formula replace also ZEIT with TIME

Also, Excel unformatted dates are DAYS, not hours. And it's
from 1900, not 1901. Hours are always fractional parts:

1/1/01 0:00	367
1/1/01 12:00	367.5

It sure sounds like the number being given you ISN'T the
same as Excel date serial numbers.



More information about the Python-list mailing list