How Grafana's Yesterday Preset Works
When I set the time picker in Grafana to Yesterday, I noticed something curious: both the From and To fields were set to the same
value — now-1d/d. How could the same expression define both the start and end of a time range? Curious, I dug into the documentation and
source code to understand how this works.
Turns out that Grafana’s relative time syntax uses a /unit rounding operator that is context-sensitive. When used in the From field it floors to unit start, when used in the To field it ceils to unit end.
So when using now-1d/d in the From field, now-1d means “now minus 1 day”, and adding /d means “round down to the day boundary”. And using the same now-1d/d in the To field, it also starts with “now minus 1 day”, but the /d means “round up to the day boundary”. All timestamps are based on the dashboard’s configured timezone, so the exact boundaries depend on that setting.
The result: now-1d/d to now-1d/d gives you a complete calendar day.
The official docs mention some other useful expressions:
- Using
now/dtonowgives you “Today so far” (from midnight to now). - Using
now/wtonow/wgives you “This week” (from the start of the week to now). Same fornow/Mtonow/Mfor “This month.” - Using
now-1y/fytonow-1y/fygives you “Last fiscal year” (from the start of last fiscal year to the end of last fiscal year). Here fiscal year is determined by theFiscal year start monthsetting in Grafana.

Grafana time picker with the fiscal year preset
Some other interesting things I found:
- On DST transition days,
now-1d/dwith a DST-observing timezone gives 23h (spring-forward) or 25h (fall-back) - Be careful while sharing links with this preset. By default Grafana might encode the absolute timestamps in the URL, so the relative expression may not be preserved when someone else opens the link. Remember to uncheck the “Lock time range” option if you want the relative expression to be evaluated at the time of opening the link.
- Elasticsearch has similar date math syntax. Grafana might have been inspired by it. But I haven’t found this ceiling/flooring logic in Elastic’s docs.