Re: Calculate days between two dates

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Thursday, June 18, 2009, 3:03:53 PM, NDK wrote:
>
> Hi,
>
> I have two dates in freemarker and i would like to calculate the days
> between these two days. Is this possible?

No, not with built-in stuff. Ideally, the number of days should be
already in the data-model... because, the idea is that the template
doesn't calculate, only display things. Now I admit that it's not
always feasible to keep things that clean in practice. In that case,
write freemarker.template.TemplateMethodModelEx that calculates the
days, and put it into your application-specific library file (the
thing that you #import or #include everywhere... if you have a such
thing) with
<#assign daysBetween = "com.example.DaysBetweenMethod"?new()>.

> When i try to calculate it, i have an error that says my dates are not
> numerical Expressions.
>
> At the moment i just use date?date for the current day...

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.