Date Macros

Type # in any query field and pick from 35+ date macros. They resolve to ISODate values at query time, so your queries always return fresh data without manual date math.

The Problem with Date Queries

Every MongoDB developer knows this workflow: open a date calculator, figure out the timestamp for 7 days ago, format it as an ISODate string, paste it into your query, and hope you didn't get the timezone wrong.

{ "createdAt": { "$gte": ISODate("2026-01-30T00:00:00.000Z") } }

This date is hardcoded. Tomorrow you'll have to recalculate it. Next week it's completely wrong. You can't save this query and reuse it because the date is static.

The Solution: Type # and Go

With date macros, the same query becomes:

{ "createdAt": { "$gte": #last7days } }

No date math. No ISODate formatting. No timezone confusion. The macro resolves to the correct ISODate value every time you run the query.

Date macros autocomplete dropdown in Mongon showing available macros

Before and After

See how date macros simplify common queries:

Orders from the last 30 days

Before
{ "createdAt": { "$gte": ISODate("2026-01-07T00:00:00.000Z") } }
After
{ "createdAt": { "$gte": #last30days } }

Users created this month

Before
{ "joinedAt": { "$gte": ISODate("2026-02-01T00:00:00.000Z") } }
After
{ "joinedAt": { "$gte": #startOfMonth } }

Events from yesterday

Before
{ "date": { "$gte": ISODate("2026-02-05T00:00:00.000Z"), "$lt": ISODate("2026-02-06T00:00:00.000Z") } }
After
{ "date": { "$gte": #yesterday, "$lt": #today } }

All Available Macros

Mongon ships with 35+ date macros organized into five categories.

Relative Time

Go back a fixed amount of time from right now.

MacroResolves to
#last1hour1 hour ago
#last24hours24 hours ago
#last7daysExactly 7 days ago
#last30daysExactly 30 days ago
#last90daysExactly 90 days ago
#last1month1 calendar month ago
#last3months3 calendar months ago
#last6months6 calendar months ago
#last1year1 calendar year ago

Named Days

Common day references that resolve to midnight boundaries.

MacroResolves to
#nowCurrent date and time
#todayStart of today (00:00:00)
#yesterdayStart of yesterday (00:00:00)
#tomorrowStart of tomorrow (00:00:00)

Start of Period

Jump to the beginning of a calendar period.

MacroResolves to
#startOfDayStart of today (00:00:00)
#startOfWeekStart of current week (Monday)
#startOfMonthFirst day of current month
#startOfQuarterFirst day of current quarter
#startOfYearJanuary 1 of current year

End of Period

Jump to the last moment of a calendar period.

MacroResolves to
#endOfDayEnd of today (23:59:59.999)
#endOfWeekEnd of current week (Sunday)
#endOfMonthLast moment of current month
#endOfQuarterLast moment of current quarter
#endOfYearDecember 31 23:59:59 of current year

Previous Period

Reference the start of the previous calendar period.

MacroResolves to
#startOfLastWeekStart of last week
#startOfLastMonthFirst day of last month
#startOfLastQuarterFirst day of last quarter
#startOfLastYearJanuary 1 of last year
#endOfLastWeekEnd of last week
#endOfLastMonthLast moment of last month
#endOfLastQuarterLast moment of last quarter
#endOfLastYearLast moment of last year

Works Everywhere

Date macros aren't limited to the filter field. You can use them in:

  • Filters — find documents created in the last week, month, or year
  • Aggregation pipelines — use in $match, $addFields, or any stage that accepts date values
  • Projections — compute date differences on the fly
  • Saved queries — save a query with #last24hours and it always returns fresh data

Always Relative, Never Stale

Macros evaluate at query time, not when you type them. A saved query with #last30days will always return the last 30 days of data, no matter when you run it. No more updating hardcoded dates every morning.

This makes macros perfect for dashboards, monitoring queries, and any workflow where you revisit the same query regularly.

Autocomplete Built In

You don't need to memorize any macro names. Type # in any query field and the autocomplete dropdown appears instantly. Scroll through the list, type a few characters to filter, and press Enter to insert.

Included in the Free Plan

All 35+ date macros are available on the free plan. No premium upgrade required. Every Mongon user gets the full macro library from day one.

Try Mongon for free35+ date macros included in the free plan