I am using Google Apps Script to do something with Gmail messages. To retrieve messages within a specific time range, I use the GmailApp search method. It seems that Gmail will round up the timestamp of the messages to minutes so I could not get results which I would expect to have.
Let's say we have 3 messages with timestamps
- 2020-10-15 11:14:41
- 2020-10-15 11:38:49
- 2020-10-15 11:59:26
When I search the messages by query "after:1602759600 before:1602730800" (from 2020-10-15 11:00:00 to 2020-10-15 12:00:00), only 2 messages were returned. It seems that Gmail rounds up the timestamp of the messages to minutes, where the "11:59:26" message was treated as "12:00" (It also appears as "12:00" in the inbox of the Gmail page)
If I set the query to "after:1602730800 before:1602766800" (from 2020-10-15 12:00:00 to 2020-10-15 13:00:00), the message stamped with "2020-10-15 11:59:26" returned as the search result.
To investigate this, I sent another 2 messages to see how Gmail rounds up. I sent the messages at 12:59:15 and 12:59:45 respectively, this time Gmail rounds down the "12:59:15" to "12:59" and the "12:59:45" to "13:00".
Does anybody knows what is behind the box?