Results 1 to 3 of 3

Thread: date:-0month ???

  1. #1
    Join Date
    Dec 2007
    Rep Power

    Default date:-0month ???

    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

  2. #2
    Join Date
    Sep 2005
    Rep Power


    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:<=3/5/2008" and take complete control over the range yourself) but instead to allow people to quickly specify searches they have might have to do.

    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".
    Bugzilla - Wiki - Downloads - Before posting... Search!

  3. #3
    Join Date
    Dec 2007
    Rep Power


    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.

Similar Threads

  1. occasional imapsync invalid date format error
    By oayfer in forum Migration
    Replies: 5
    Last Post: 03-29-2011, 10:27 PM
  2. Zimbra fails after working for 2 weeks
    By Linsys in forum Administrators
    Replies: 10
    Last Post: 10-07-2008, 12:42 AM
  3. IMAP Sync and "received" date
    By Zenitram in forum Migration
    Replies: 34
    Last Post: 03-16-2007, 04:34 PM
  4. Replies: 29
    Last Post: 02-18-2007, 06:45 PM
  5. Date Received Is Incorrect in Web Interface
    By wowzimbra in forum Administrators
    Replies: 6
    Last Post: 05-18-2006, 03:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts