Wiki - Calculate custom dates for query, how?

Posts: 37
Joined: Mon Sep 29, 2014 7:00 pm

Wiki - Calculate custom dates for query, how?

Postby DCwom » Fri Jan 30, 2015 6:10 pm

I'm trying got do a query of work records for 7 days prior to a user specified date (i.e. the last 7 days). I've had some success using the $datetool from the wiki script extension and subtracting the number of milliseconds in 7 days (1209600000), but I really want an interval from 12:01AM to 11:59PM. I would like to use something more exact like Julian days but I cannot find a way to make that work. I've tried the following code but I always get the date to be Dec 31, 1969, likely because I'm not preserving the date object.

Code: Select all

#set($sysDate= $dateTool.getSystemDate())
#set($julianDATE = $dateTool.format('D',$dateTool.toDate($sysDate)))
#set($def7days = $mathTool.sub($numberTool.toNumber($julianDATE), $numberTool.toNumber("7")))
#set($weekEarly = $dateTool.format('yyyy',$dateTool.toCalendar($def7days )))
7 Days earlier is: $weekEarly\\

Does anyone have any ideas?

Posts: 181
Joined: Thu Nov 05, 2009 3:24 pm

Re: Wiki - Calculate custom dates for query, how?

Postby martins » Mon Feb 02, 2015 6:31 am

If you like to query for workitems which where created 7 days ago you can use something like

Code: Select all

#set($wis = $trackerService.queryWorkItems("created:[$today - 7d$ TO $today - 7d$]","id"))

You don't have to calculate the exact date in advance.

Kind regards


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: Matveykit and 17 guests