[Zope] Subtracting 2 dates from each other

Gitte Wange gitte@mmmanager.org
Mon, 28 May 2001 15:16:11 +0200


On Monday 28 May 2001 15:18, Peter Bengtsson wrote:
> What do you really want?
>
> >>> from DateTime import DateTime
> >>> date1 = DateTime('2001/05/25 20:30:00')
> >>> date2 = DateTime('2001/05/25 19:00:00')
> >>> res = date1 - date2
> >>> type(res)
>
> <type 'float'>
>
> >>> hours = res*24
> >>> type(hours)
>
> <type 'float'>
>
> >>>  print hours
>
> 1.5
>
> Do you want to calculate how many hours there are between two dates? Or how
> many days (like 'res' above)?
> If your result is unchanging even though you change the dates, could it be
> because you're doing some int() roundoff or something so that you loose the
>
> accuracy in the hours; like this:
> >>> print int(res*24)
>
> 1
>
> Peter

I want to know EXTACTLY how long time (in hours, minutes, seconds) there is 
between Date1 and Date2 ...

Anyone ???

Gitte

>
> ----- Original Message -----
> From: "Gitte Wange" <gitte@mmmanager.org>
> To: "Tino Wildenhain" <tino@wildenhain.de>
> Cc: <zope@zope.org>
> Sent: Monday, May 28, 2001 2:12 PM
> Subject: Re: [Zope] Subtracting 2 dates from each other
>
> > On Monday 28 May 2001 14:04, you wrote:
> > > Hi Gitte,
> > >
> > > how about Date1 - Date2 ? :)
> > >
> > > Of course they must be DateTime instances, not strings.
> > >
> > > Regards
> > > Tino
> >
> > That doesn't work ..
> > Well it subtracts something .... but the result is very weird.
> > An example:
> > Date1 = 2001/05/25 20:30:00
> > Date2 = 2001/05/25 19:00:00
> >
> > Expected result: 01:30:00
> > The result  I got: 01:00:00
> >
> > And changing the dates doesn't change the result ... why ???
> >
> > Gitte
> >
> > > --On Montag, 28. Mai 2001 08:15 +0200 Gitte Wange <gitte@mmmanager.org>
> > >
> > > wrote:
> > > > Hello,
> > > >
> > > > I need to subtract to dates from each other.
> > > > I have searched the archives but haven't found anything useful.
> > > > Hope someone here could help me.
> > > >
> > > > Regards,
> > > > --
> > > > ************************
> > > > Gitte Wange Jensen
> > > >
> > > > System Squid Developer
> > > > MMManager Aps
> > > > +45 29 72 79 72
> > > >
> > > > gitte@mmmanager.org
> > > > ************************
> > > >
> > > > _______________________________________________
> > > > Zope maillist  -  Zope@zope.org
> > > > http://lists.zope.org/mailman/listinfo/zope
> > > > **   No cross posts or HTML encoding!  **
> > > > (Related lists -
> > > >  http://lists.zope.org/mailman/listinfo/zope-announce
> > > >  http://lists.zope.org/mailman/listinfo/zope-dev )
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )