[Zope-dev] Can I create dtml to calculate a date 30 days ago?

Nick Garcia ngarcia@codeit.com
Thu, 13 Apr 2000 15:43:36 -0700


jpenny@universal-fasteners.com wrote:
> 
> I would like to do the following:
> <dtml-call "REQUEST.set('magicdate', DateTime()-days)">
> where days is a variable set in a form in a higher level
> web page.  It does not work, complains about
> "bad operand for unary -".
> 
> Is there a way in DTML to do this?
> (And if so, what is it?).
> 
> I am usually pretty good at trying quoting variants until I
> stumble accross one that works, but I just can't find it this
> time.

Make sure that your variable 'days' is an int.  It sounds like it might
be a string.  Also, although this was probably a type, it should be
_.DateTime(), not just DateTime().  

If you do:
<dtml-call "REQUEST.set('magicdate', _.DateTime()-_.int(days))">

it should work.

-- 
Nick Garcia | ngarcia@codeit.com
CodeIt Computing | http://codeit.com