Expression functions
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()
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"lessThan": "now()"
}
]
}
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"greaterThanOrEqualTo": "now(-1)"
}
]
}
startOfDay()
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"greaterThanOrEqualTo": "startOfDay()"
}
]
}
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"greaterThanOrEqualTo": "startOfDay(-1w)"
}
]
}
endOfDay()
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"greaterThanOrEqualTo": "startOfDay(-1d)"
},
{
"field": "sys.version.created",
"lessThanOrEqualTo": "endOfDay(-1d)"
}
]
}
startOfWeek()
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"lessThan": "startOfWeek()"
}
]
}
endOfWeek()
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"greaterThanOrEqualTo": "startOfWeek(-1)"
},
{
"field": "sys.version.created",
"lessThanOrEqualTo": "endOfWeek(-1)"
}
]
}
startOfMonth()
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"greaterThanOrEqualTo": "startOfMonth()"
}
]
}
endOfMonth()
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"greaterThanOrEqualTo": "startOfMonth(-1y)"
},
{
"field": "sys.version.created",
"lessThanOrEqualTo": "endOfMonth(-1y)"
}
]
}
startOfYear()
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"greaterThanOrEqualTo": "startOfYear()"
}
]
}
endOfYear()
{
"pageIndex": 0,
"pageSize": 25,
"where": [
{
"field": "sys.version.created",
"greaterThanOrEqualTo": "startOfYear(-1y)"
},
{
"field": "sys.version.created",
"lessThanOrEqualTo": "endOfYear(-1)"
}
]
}