Skip to main content

ZenQL search – relative time period

Log in to add to favourites

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
PeriodSyntaxExample
Year{int}y1y
Month{int}M2M
Week{int}w2w
Day{int}d5d
Hour{int}h10h
Minute{int}m15m

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)

Still need help?

If you still need help after reading this article, don't hesitate to reach out to the Contensis community on Slack or raise a support ticket to get help from our team.
New support request