date:-0month ???

Post feedback about our hosted demo or your local install. Tell us what you love and/or what you’d like to see added in the future.
Mike Scholes
Outstanding Member
Outstanding Member
Posts: 201
Joined: Fri Sep 12, 2014 11:14 pm

date:-0month ???

Postby Mike Scholes » Fri Apr 04, 2008 6:04 am

Today is 4th Apr 2008, my search string is date:-0month, the results show mails from 25th Mar to today, the last 10 days. date:-1month gives mail from 25th Apr to 24th Mar. What is this fixation with the 25th of the month. I would have thought date:-0month would give mails from 4th Mar to today, 4th Apr.
5.0.4 F7


tim brennan
Advanced member
Advanced member
Posts: 93
Joined: Fri Sep 12, 2014 9:55 pm

date:-0month ???

Postby tim brennan » Fri Apr 04, 2008 5:19 pm

Two separate things going on here:
1) Looks like there's a bug with "month" and "year" relative operations -- we're not zeroing out the range correctly (#$*! Java Calendar APIs, some fields are 0-indexed and some are 1-indexed and so easy to get them mixed up). I've filed bug 26744 on this.

2) Your comment "I would have thought date:-0month would give mails from 4th Mar to today, 4th Apr" is not correct because you aren't taking into account the matching window. It's important to understand that the "date" operator has an implicit matching window. When you specify date: you don't really mean an exact time, you really mean some kind of a range. Sometimes you want to refer to a calendar day (midnight-midnight), sometimes an hour (3:00 to 4:00), sometimes a week (sunday-sunday), etc. In order to take this into account, when you specify a relative date the granularity of the range is implied by the operator you use.
The reason for this will become clear if you look at the most common cases. Lets assume that the current date is 4/4/2008 and the time is 2:36pm.
date:-1h  "last hour"  -- 1pm - 2pm on 4/4

date:-1d "yesteday" -- midnight on 4/3 until midnight on 4/4

date:-1w "last week" -- Sunday 3/23 to Sunday 3/30

date:-1m "last month" -- 3/1 to 4/1

date:-1y "last year" -- 2007
Remember the goal here is not to create something infinitely expressible (you can always just enter "date:>=3/4/2008 and date:
So date:-0m should mean "4/1 to 5/1"....but it's broken (bug 26744 ). If you really really want the exact day that happened a month ago, you want "-31d" (or -30d or -28d, depending on the month) -- there's no way to express it directly in a relative date...although honestly I don't think it's that useful (do you have a real-world use case for this?)
Now -- just because I'm on a roll -- let's see what happens when you use a relative date with the "before" or "after" operators:
after:-1d means "after yesterday" -- so today or later

after:-2h means "after the hour that was 2 hours ago" -- so after 1:00 (0 hours ago is 2-3, 1 hour ago is 1-2, so 2 hours ago is 12-1)

after:-1y means "date:>=1/1/2008"

after:-31d means "date:>=3/5/2008"

after:-1m means "date:>=4/1/2008"

The last two are counterintuitive, but correct. "-31d" evaluates to the range (3/4/2008 0:00 to 3/5/2008 0:00) and after means ">= the end of the range.". This is easiest to grok if you think that "-1d" means "yesterday" so after:-1d means "after yesterday". For after:-1m you're talking about "After last month" which is "this month".
Mike Scholes
Outstanding Member
Outstanding Member
Posts: 201
Joined: Fri Sep 12, 2014 11:14 pm

date:-0month ???

Postby Mike Scholes » Sun Apr 06, 2008 2:15 am

Thanks for your detailed reply. You mention bug 26744, if this means that when the bug is rectified that right now, April, date:-0month will give me all emails in April then great, date:-1month gives me emails in March, again that's good. I know that all queries need a range it was just weird that it seems that the 25th seemed to play a part in this. I was expecting the range to be defined something like now() - xdays with now() being the definitive start point.

Return to “Users”

Who is online

Users browsing this forum: No registered users and 6 guests