Skip to main content
Browse Documentation

Expression functions

Created by zengenti, last updated 23 Sep 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.

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()

List records created prior to the current UTC DateTime.
{
    "pageIndex": 0,
    "pageSize": 25,
    "where": [
        {
            "field": "sys.version.created",
            "lessThan": "now()"
        }
    ]
}
List records created in the last 24 hours (day element inferred).
{
    "pageIndex": 0,
    "pageSize": 25,
    "where": [
        {
            "field": "sys.version.created",
            "greaterThanOrEqualTo": "now(-1)"
        }
    ]
}

startOfDay()

List records created since the start of today.
{
    "pageIndex": 0,
    "pageSize": 25,
    "where": [
        {
            "field": "sys.version.created",
            "greaterThanOrEqualTo": "startOfDay()"
        }
    ]
}
List records created since the start of this day last week.
{
    "pageIndex": 0,
    "pageSize": 25,
    "where": [
        {
            "field": "sys.version.created",
            "greaterThanOrEqualTo": "startOfDay(-1w)"
        }
    ]
}

endOfDay()

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

startOfWeek()

List Records created prior to the start of the current week.
{
    "pageIndex": 0,
    "pageSize": 25,
    "where": [
        {
            "field": "sys.version.created",
            "lessThan": "startOfWeek()"
        }
    ]
}

endOfWeek()

List records created last week (week element inferred).
{
    "pageIndex": 0,
    "pageSize": 25,
    "where": [
        {
            "field": "sys.version.created",
            "greaterThanOrEqualTo": "startOfWeek(-1)"
        },
        {
             "field": "sys.version.created",
            "lessThanOrEqualTo": "endOfWeek(-1)"
        }
    ]
}

startOfMonth()

List records created since the start of the current month.
{
    "pageIndex": 0,
    "pageSize": 25,
    "where": [
        {
            "field": "sys.version.created",
            "greaterThanOrEqualTo": "startOfMonth()"
        }
    ]
}

endOfMonth()

List records created in this month last year.
{
    "pageIndex": 0,
    "pageSize": 25,
    "where": [
        {
            "field": "sys.version.created",
            "greaterThanOrEqualTo": "startOfMonth(-1y)"
        },
        {
             "field": "sys.version.created",
            "lessThanOrEqualTo": "endOfMonth(-1y)"
        }
    ]
}

startOfYear()

List records created so far this year.
{
    "pageIndex": 0,
    "pageSize": 25,
    "where": [
        {
            "field": "sys.version.created",
            "greaterThanOrEqualTo": "startOfYear()"
        }
    ]
}

endOfYear()

List records created last year (year element inferred in "lessThanOrEqualTo" operator).
{
    "pageIndex": 0,
    "pageSize": 25,
    "where": [
        {
            "field": "sys.version.created",
            "greaterThanOrEqualTo": "startOfYear(-1y)"
        },
        {
             "field": "sys.version.created",
            "lessThanOrEqualTo": "endOfYear(-1)"
        }
    ]
}