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

Expression functions

Created by zengenti, last updated 14 Dec 2021

Expression Functions are built-in functions that can be used in search queries in place of static values in your where operators.  The functions generate a value when they are executed on the server by the API.

Expression Functions make it easier for you to run precise filters against properties on your content records.  This enables you to retrieve the exact records you want to see with minimal client-side effort, allowing the API to take care of dynamically generating accurate and correctly formatted values.

Date Functions

  • now()
  • startOfDay()
  • endOfDay()
  • startOfWeek()
  • endOfWeek()
  • startOfMonth()
  • endOfMonth()
  • startOfYear()
  • endOfYear()

These functions generate a UTC datetime value at the specific point in time at which they are executed server-side and are accurate to the millisecond. For example, startOfDay() will resolve to the first millisecond of today's date in UTC time; startOfWeek() will resolve to the first millisecond of the Monday of the week in which today's date (in UTC time) falls.

All date functions have 2 overloads; one that will accept a Relative Time Period as a parameter which will offset the datetime value generated by the function, and another that will accept an integer and the date element will be inferred by the element the function operates on.

Examples

now()

JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "lessThan": "now()" } ] }
JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "greaterThanOrEqualTo": "now(-1)" } ] }

startOfDay()

JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "greaterThanOrEqualTo": "startOfDay()" } ] }
JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "greaterThanOrEqualTo": "startOfDay(-1w)" } ] }

endOfDay()

JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "greaterThanOrEqualTo": "startOfDay(-1d)" }, { "field": "sys.version.created", "lessThanOrEqualTo": "endOfDay(-1d)" } ] }

startOfWeek()

JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "lessThan": "startOfWeek()" } ] }

endOfWeek()

JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "greaterThanOrEqualTo": "startOfWeek(-1)" }, { "field": "sys.version.created", "lessThanOrEqualTo": "endOfWeek(-1)" } ] }

startOfMonth()

JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "greaterThanOrEqualTo": "startOfMonth()" } ] }

endOfMonth()

JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "greaterThanOrEqualTo": "startOfMonth(-1y)" }, { "field": "sys.version.created", "lessThanOrEqualTo": "endOfMonth(-1y)" } ] }

startOfYear()

JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "greaterThanOrEqualTo": "startOfYear()" } ] }

endOfYear()

JSON
{ "pageIndex": 0, "pageSize": 25, "where": [ { "field": "sys.version.created", "greaterThanOrEqualTo": "startOfYear(-1y)" }, { "field": "sys.version.created", "lessThanOrEqualTo": "endOfYear(-1)" } ] }