Since (for some internal reasons) I couldn't use the suggestion, i.e. to upload messages from Gmail to Google Sheets and try to filter them there, I came with a semi-automatic, semi-manual way using Excel, which is also inspired by user0's answer.
To cut the long story short (details, discussion and alternative approaches are all here) what I did was:
- Fill tha A column with all the dates in desired range (1,5+ year, 610 dates / rows in my case).
- Set a fixed start time and end time and store it in some separate cells (C1 and E1).
- Generate dates with given start and end time:
- start date:
=DATE(YEAR(A4);MONTH(A4);DAY(A4))+TIME(HOUR($C$1);MINUTE($C$1);SECOND($C$1))
,
- end date:
=DATE(YEAR(B4);MONTH(B4);DAY(B4))+TIME(HOUR($E$1);MINUTE($E$1);SECOND($E$1))
.
- Convert these dates into Unix timestamp:
- start date:
=(B4-DATE(1970;1;1))*86400
,
- end date:
=(C4-DATE(1970;1;1))*86400
.
- Concatenate resulting values to get filtering string and URL:
- filtering string:
="after:" & D4 & " before:" & E4
,
- URL:
="https://mail.google.com/mail/u/0/#search/after%3A" & E4 & "+before%3A" & F4
.
And I have resulted with a long list of filtering strings and URLs, like:
after:1496419200 before:1496390400
,
https://mail.google.com/mail/u/0/#search/after%3A1496350800+before%3A1496376000
,
ready to be pasted into Gmail's search box:
or into browser's address bar.
An example of the resulting sheet (get it here):
There are some more modifications to above to be considered that includes:
Note, that the above approaches solves "weekends" problem directly while original blog post) uses separate column instead (see screenshot above) and thus formulas are a bit different.
Sources: