Knowledge base · Studio 3T Desktop IDE

Date Tags

By Dj Walker-Morgan · Updated

Date tags are placeholders for different date operations relative to when a query is run. Date tags make date fields easier to work with by saving you from having to perform calculations with the MongoDB Date() function.

Studio 3T converts the date tags when the query is run into the appropriate MongoDB query, using greater than and less than operators to cover the calculated time range.

Studio 3T's date tags help you query MongoDB date fields by adding greater and less than operators to your MongoDB query

For example, in the screenshot above, the query

{ "registered_on": #today }

expands into

 "registered_on" : { rn            "$gte" : ISODate("2024-05-08T00:00:00.000+0000"), rn            "$lt" : ISODate("2024-05-09T00:00:00.000+0000")rn        }rn    }

and the range is automatically updated when that query is run, to reflect the time and date of that run.

Where can Date tags be used?

You can use Date tags in the Collection tab’s Query bar, IntelliShell, Visual Query Builder, in the Aggregation editor when creating a $match stage, and in find and aggregation queries used in Exports.

In IntelliShell, if you run an aggregation query that uses date tags and then you export it, the date tags are converted to literal date values.

Relative Date Tags

Tag Definition
Hour-related tags
#nextNhours Within the next N hours from now
#nexthour Within the next hour
#lastNhours Within the last N hours up to now
#lasthour Within the last hour
General past / future tags
#uptonow Any time before now (“in the past”)
#fromnow Any time from now (“in the future”)
#aftertoday Any time after today
#beforetoday Any time before today
Days-related tags
#today Any time today
#yesterday Any time yesterday
#tomorrow Any time tomorrow
#nextNdays The rest of today + the next N calendar days
#nextNcaldays The next N calendar days following today
#lastNdays the last N calendar days + the start of today until now
#lastNcaldays The last N calendar days before today
Weeks related tags
#nextNweeks The rest of today + the next N weeks – equivalent to #nextN*7days
#nextNcalweeks The next N calendar (Mon-Sun) weeks after the current calendar week
#nextweek The next week – the rest of today plus the next 7 calendar days, equivalent to #next7days
#nextcalweek The next calendar week following the current calendar week
#lastNweeks the last N weeks + the start of today until now – equivalent to #lastN*7days
#lastNcalweeks The last N calendar (Mon-Sun) weeks before the current calendar week
#lastweek The last 7 calendar days + the start of today until now, equivalent to #last7days
#lastcalweek The calendar week before the current calendar week
#thisweek
#thiscalweek
The current calendar week (Mon – Sun)
Months related tags
#nextNmonths The next N months from and including the rest of today
#nextNcalmonths The next N calendar months after the current month
#nextmonth The next month from today including the rest of today – equivalent to #next1months
#nextcalmonth The next calendar month following the current month
#lastNmonths The last N months up to and including the start of today until now
#lastNcalmonths The last N calendar months before the current month
#lastmonth The last month leading up to and including the start of today until now – equivalent to #last1month
#lastcalmonth The last calendar month before the current month
#thismonth
#thiscalmonth
The current calendar month
Years related tags
#nextNyears The next N years from now and including the rest of today
#nextNcalyears The next N calendar years after this year
#nextyear The next year from now, including the rest of today – equivalent to #next1years
#nextcalyear The next calendar year after this year
#lastNyears The last N years up to and including the start of today until now
#lastNcalyears The last N calendar years before this year
#lastyear The last year up to and including the start of today until now – equivalent to #last1years
#lastcalyear The last calendar year before this year
#thisyear
#thiscalyear
The current calendar year

With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes, including personalized advertising (“performance”), to provide you with additional functions (“functional”), and to show content from social media platforms, such as embedded videos (“social media”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data. Please choose for which purposes you wish to give us your consent and store your preferences by clicking on “Accept selected”. You can find further information in section 9 of our Privacy Policy.

Manage consent preferences