Manipulating with date functions in makumba (adding or substracting hours)
I want to get current date +/- some hours.
According to docummentation, one of those should work:
date_sub(now(), interval 1 hour)
date_sub(current_time(), interval 1 hour)
but it doesn't. I use Makumba version is开发者_StackOverflow 0.8.2.5.1
Am I doing something wrong?
Indeed, these functions work only in Makumba >= 0.9 (and in some versions <= 0.7)
A workaround in 0.8 is to do the date programmatically via JSP tags, e.g.:
<jsp:useBean class="java.util.Date" id="oneHourAgo" />
<jsp:setProperty name="oneHourAgo" property="hours" value="${oneHourAgo.hours - 1}" />
and then use the variable inOneHour (which is in the pageContext) as a named parameter in your query, e.g.:
<mak:list from="company.Company c" where="c.TS_create >= $oneHourAgo">
....
</mak:list>
Unfortunately in the versions prior to 0.9 the date_sub
and date_add
functions don't get parsed correctly so they don't work properly. (it should actually be removed from the documentation)
In the version 0.9+ you'll have new functions dateAdd
and dateSub
and for your case you would do:
dateSub(now(),1,'hour')
and that should work.
精彩评论