It's all about the answers!

Ask a question

relative date query not working properly?

Susan Hanson (1.6k2200194) | asked Jun 28 '13, 8:13 a.m.
I'm seeing an oddity when doing queries with a Relative Date.

I do a query for all Unresolved work items that have a Creation Date before (including) then 2years and relative date.
I get 4,700 work items

If I change it to a specific date and pick today
I get 3,580 work items

It looks like the "2 years relative" says basically only look at the YEAR, as it looks like I get anything in 2011 or earlier,  including ones in December 2011, which is actually not 2 older than 2years ago taking into account what day today is.

Is this normal?  It doesn't seem very logical to me.

One answer

permanent link
Eric Jodet (6.3k5111120) | answered Jul 05 '13, 5:51 a.m.
 Hello Susan,
I debugged this area of the code and here is what I observe:
- relative date : specific date = 5 jul 2012 (which is 1 year from now)
we use a timestamp like 2012-07-05 11:32:00.0
- relative date : 1 year ago
we compute a time span like 
Start date: 2012-01-01 00:00:00.0
End date: 2012-12-31 23:59:59.999
using RelativeDateVariable#evaluate() method

This might explain the difference in the results you see and that I can also observe on

I guess you would expect the calculated time span to match the timestamp.

I will notify a developer from the Work Item Team so as to provide more insight here.


Your answer

Register or to post your answer.