I have a ton of email in my Gmail archive, and sometimes need to dig through older email. Problem is, if I do a search, it shows me all the most recent matches first when what I really want to do is, say, search for messages more than a year old, or 12-18 months ago or similar. Is there any way to do a more sophisticated search than just by keyword?
I’m a big fan of Google’s Gmail service, and have found that experimentation is a great thing in terms of its search, just as poking around and trying different things in Google’s main search system can real all sorts of useful capabilities, including the ability to convert measurement and weight units and the ability to solve even fairly complicated formulas.
In Gmail, as with many Google properties, the real secret is to pay attention to the small print (does that sound like something your Dad might have told you when you were younger? 🙂
For example, when you’re in Gmail, here’s what you see in the search area:
Look closely. See the link “Show search options”? Click it:
That’s pretty interesting, isn’t it? 🙂
Now let’s poke around a bit. If I do a search for “contract” on email that’s between one and two years old (which is done, rather awkwardly, as being within six months of 18 months ago), the resultant URL is:
So we can see that Gmail uses a different sort of URL notation for advanced searches with “#advanced-search/subset=all”. The keyword is in the “has=” value, and then there’s a “date=” and a “within=”. The question is, can we use those as predicates directly in a search?
I’ll try it, searching for “contract within:6m date:01/01/2008”. The result? Zero.
Ah, well, okay, so that doesn’t work. But what does?
Turns out that with a big of digging, Google has an advanced search help page that details the following long list of predicates:
|from:||message sender||“from:dave” = all mail with ‘dave’ in sender field|
|to:||message recipient||“to:sydney” = all mail with ‘sydney’ in the destination field (including mail not from you)|
|subject:||message subject||“subject:dinner” = all mail that has ‘dinner’ in the subject|
|after:||messages sent after a certain date||“after:2009/03/01” = all mail sent after March 1, 2009 (date format must always be YYYY/MM/DD)|
|before:||messages sent before a certain date||“before:2009/01/01” = all mail sent before January 1, 2009.|
There are many more entries (see the original Google article) but these are the key ones that most power users are going to focus upon. This also gives us the tools we need to do the search we really want to do:
“contract before:2008/06/01 after:2007/06/01”
That, finally, gives us all email that contains the word “contract” and was sent or received between June 1, 2007 and June 1, 2008.
All messages more than a year old? Just use “before:” and follow it with the previous year and current month and day. As I write this, it’d be “2008/06/21”.
Sometimes experimentation fails, as we saw with my first stab, but exploring the help menus and everything else definitely reveals that the Gmail search system has quite a bit more power than is immediately obvious, and quite a bit more power than even you get with the ‘advanced search’ pane.