[Zope] How to subtract one date from another?

Steve Alexander steve@cat-box.net
Wed, 26 Apr 2000 18:18:18 +0100


jens ebaer wrote:
> 
> Hi all,
> 
> I have to to this: date - date = 20 days. (2000-5-5 - 2000-5-2 = 3 days)
> 
> I checked Zope Quick Reference but couldnīt find a function which provide
> this.
> 
> May someone has a python function and can give me this funktion.
> 

Where date2 and date1 are DateTime objects, and date2 is later than
date1:

<dtml-var "date2-date1"> gives you the number of days difference as a
floating point number.

<dtml-var "_.int(_.round(date2-date1))"> gives you the number of days as
a rounded integer. (That is, half days get counted as a whole day).

Make a string into a DateTime object using _.DateTime('some date
string').

--
Steve Alexander
Software Engineer
Cat-Box limited