Skip to main content

Cookie control banner

Necessary Cookies
These cookies are necessary for this website to function correctly. They are set when you perform certain actions on the site, such as creating an account, logging in, changing your privacy preferences or submitting a form. You can block these cookies in your browser, but this will stop parts of the site from working properly.
Functional Cookies
These cookies allow the website to provide extra functionality and more personalised experiences. They may be set by us or by third party providers whose services we have added to our pages. If you choose not to allow these cookies, these services may not work correctly.
Analytical Cookies
These cookies record anonymous data on how visitors use our website to help us monitor how well our website works. This data includes how many people have looked at specific pages, how long visitors stay on the site, and what devices they use. We use this data to identify changes that we could make to improve your experience and make our website more efficient.
Marketing Cookies
We set some cookies so you are shown more relevant marketing content. These include cookies from third-party advertising networks to show you different adverts on their services if you have previously visited our site. If you choose not to allow these cookies, you may experience less relevant advertising on other sites.
Browse Documentation

ZenQL search – relative time period

Created by r.saunders, last modified by r.bromley on 13 Feb 2022

A relative time period is a token that can convert a date and time value, relative to the current date and time (UTC). It can be used in an operator or as a parameter of a date time function.

Syntax

The token consists of 1 or more space-delimited segments and can optionally contain a preceding plus or minus sign. The sign can only be used once and is applied to the whole expression. When combining segments, there is no need enclose them in double quotes.

<token>:=
    [- | +]<segment>[ <segment> ...n]

<segment>:=
    <int>y|M|w|d|h|m

Supported relative periods
Period Syntax Example
Year {int}y 1y
Month {int}M 2M
Week {int}w 2w
Day {int}d 5d
Hour {int}h 10h
Minute {int}m 15m

Examples

  • Show all items that have been created in the last 24 hours.
    sys.version.created >= -1d
  • Used stand-alone to list records created in the last month plus 1 week.
    sys.version.created >= -1M 1w
  • Used as a parameter to an Expression Function to list records created last year. The year is inferred by the date function.
    sys.version.created >= startOfYear(-1) and <= endOfYear(-1)