Bugzilla has a hidden feature that lets you search (and report) by relative dates.
For example, say you wanted to search for everything where the status was changed in the last week. If today is March 8th the obvious way to do this looks like:
Of course if you wanted to run this every day you’d have to update the date every day.
A better way to do this is to use relative dates. Relative meaning relative to today.
Note the use of “-1w” rather than “2016-04-01” this means use the date back 1 week from today.
There are 5 relative date options in Bugzilla 5
- h – for hours
- d – for days
- w – for weeks
- m – for months
- y – for years
Dates can be relative both forwards and backwards. I.e. “30d” is 30 days in the future whereas “-30d” is 30 days in the past.
Something to note is that the time of day is part of the relative date. So if it is Mar 4, 2016 08:00 and you do a “-1d” Bugzilla translates that to “Mar 3, 2016 08:00”
“Start of” Suffix
If you really wanted Bugzilla to search for “Mar 3, 2016 00:00” you can use the letter “s” on the end to represent “start of”, e.g. “-1ds” would do the right thing in this case.
The different units work a little differently when paired with the start suffix. If we assume it is Mar 8, 2016 08:15 then
- -1h yields Mar 8, 2016 07:15
- -1hs yields Mar 8, 2016 07:00
- -1d yields Mar 7, 2016 08:15
- -1ds yields Mar 7, 2016 00:00
- -1w yields Mar 1, 2016 08:15
- -1ws yields Apr 27, 2016 00:00
- -1m yields Apr 8, 2016 08:15
- -1ms yields Apr 1, 2016 00:00
- -1y yields Mar 8, 2015 08:15
- -1ys yields Jan 1, 2015 00:00
Some of this seems a little odd, but we can make use of them like so:
- “year to date” can be represented as “-0ys”
- “month to date” can be represented as “-0ms”
- “week to date” can be represented as “-0ws” (the week starts on Sunday)
- “today” can be represented as “-0ds”
- “this hour” can be represented as “-0hs”
Combining the Options
We can use combinations of these relative date specifiers to get a few other commonly used date ranges.
- “yesterday” is a combination of “-1ds” and “-0ds”
- “last week” is a combination of “-1ws” and “-0ws”
- “last month” is a combination of “-1ms” and “-0ms”
- “last year” is a combination of “-1ys” and “-0ys”