Hi! Eugen Colesnicov wrote: > I checked this example and your script - it is not correct, because you > compare separately year, month and day of document with current date - year, > month and day-100. But if, for example now is 02 january, your script give > uncorrect result, becase I also should change year and month (and year), > then I want to get date BEFORE 100 days of 02 january. > You are completely right: it is clearly stated in the example. They talked only about "current" day, week and month. Sorry about being "too fast" and don't think enough before posting! > Need to make arithmetical operations with dates and these operations should > consider also possible transitions of month and year when day changed ... > In any case - thanks! > > I found the answer - need to use special velocity object $datetool > Example: > #set ($d = 5) - days interval which I need > #set ($ms = $d * 24 * 60 * 60 * 1000) - Calculating internal in > Milliseconds > > #set ($calendar = $datetool.getCalendar()) > #set ($currentTime = $calendar.getTimeInMillis()) > #set ($targetTime = $currentTime - $ms) > #set ($void = $calendar.setTimeInMillis($targetTime)) > #set ($targetDate = $calendar.getTime()) > #set ($targetYear = $datetool.getYear($targetDate)) :get year of > a date = currentdate - 5 days > #set ($targetMonth = $datetool.getMonth($targetDate) + 1) :get month of a > date = currentdate - 5 days > #set ($targetDay = $datetool.getDay($targetDate)) :get day of > a date = currentdate - 5 days > > and after this, in a hql searching, I can compare this year, month, and day > with documents year, month and day ... > >
-- Ricardo RodrÃguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
