Is it possible to query Gmail messages by timestamp?

Is it possible to search all Gmail messages within a range more granular than the day?

For instance, could I search for all chat messages from 3pm to 5pm on October 4th? How would that look?

Looking at the Gmail advanced search reference I noticed that they mention the specific times, but do not specify the format, most likely it is not supported, but I thought I would check just in case I was simply entering searches in the wrong format…

Example: after:2004/04/16 before:2004/04/18

Meaning: Messages sent between April 16, 2004 and April 18, 2004.*

*More precisely: Messages sent after 12:00 AM (or 00:00) April 16, 2004 and before April 18, 2004.


It is possible to specify time range with accuracy up to a second, because the search operators after:, before:, newer:, older: accept Unix timestamps. Using a tool such as Epoch Converter, you can find out that

  • 2014-10-04 at 15:00 (using GMT for example) has timestamp 1412434800
  • Add two hours (7200 seconds), or use the same tool again: 1412442000

Searching for after:1412434800 before:1412442000 will return the messages within this 2-hour range.

Since converting to Unix time looks like a chore, I made a bookmarklet that makes this substitution in place.

For example, after typing

after:2015/07/26 10:00 before:2015/07/27 11:30

in the search box (which would not work as is), invoke the bookmarklet and the string will be replaced by

after:1437919200 before:1438011000

(The bookmarklet interprets the given timestamps in your local time.)

The page I linked has both the source and a draggable link with the bookmarklet. For completeness, the source code is also posted below.

inp = document.querySelectorAll('input');
for (i in inp) {
  if (/(after|before|newer|older):/.test(inp[i].value)) {
    str = inp[i].value;
    times = str.match(/\d[\d\/: ]*\d/g);
    for (j in times) {
      if (Date.parse(times[j])) {
        str = str.replace(times[j], Date.parse(times[j])/1000);
    inp[i].value = str;

Source : Link , Question Author : oncifer , Answer Author : Community

Leave a Comment