[Zope] How to subtract one date from another?

Andrew Diller macdaddy@mac.com
Wed, 26 Apr 2000 14:56:43 -0400


in article list.apps.zope/390724DA.A584F61B@cat-box.net, Steve Alexander at
steve@cat-box.net wrote on 2000-04-26 1:18 PM:
> 
> <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).
> 

This is awesome-- I was just struggling with this problem. I wanted to do
the exact same thing.

One big problem with Zope is that its so easy to do these things, but _so_
hard to figure out the syntax to do it!

Here is my contribution. I create a date attribute called targetdate that
people modify. I want to have a simple integer on a page showing how many
days from _now_ till that 'target date.'

Here is my snipped that works: (thanks to the previous posts)

<dtml-let now="ZopeTime()">
<dtml-let due="targetdate">
<b><dtml-var "_.int(_.round(due-now))"></b>
</dtml-let></dtml-let>


-andy diller