Date & Time based predicate reference
This page describes and gives examples for all the date and time based predicates you can use when creating queries with the prismic.io REST API.
All of these predicates will work when used with either the Date or Timestamp fields, as well as the first and last publication dates.
Note that when using any of these predicates with either a Date or Timestamp field, you will limit the results of the query to the specified custom type.
To learn more about all the other available query predicates, check out the Query Predicate Reference page.
The date.after predicate checks that the value in the path is after the date value passed into the predicate.
This will NOT include anything with a date equal to the input value.
[date.after( $path, $date )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$date
accepted date values
ISO 8601 Standard date: "2002-08-28"
ISO 8601 Standard timestamp: "2002-08-28T15:30:00+0300"
13-digit Epoch: 1030545000000
Examples:
[date.after(document.first_publication_date, "2017-05-18T17:00:00-0500")]
[date.after(document.last_publication_date, 1495080000000)]
[date.after(my.article.release-date, "2017-01-22")]
The date.before predicate checks that the value in the path is before the date value passed into the predicate.
This will NOT include anything with a date equal to the input value.
[date.before( $path, $date )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$date
accepted date values
ISO 8601 Standard date: "2002-08-28"
ISO 8601 Standard timestamp: "2002-08-28T15:30:00+0300"
13-digit Epoch: 1030545000000
Examples:
[date.before(document.first_publication_date, "2016-09-19T14:00:00-0400")]
[date.before(document.last_publication_date, 1476504000000)]
[date.before(my.post.date, "2017-02-24")]
The date.between predicate checks that the value in the path is within the date values passed into the predicate.
[date.between( $path, $startDate, $endDate )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$startDate
accepted date values
ISO 8601 Standard date: "2002-08-28"
ISO 8601 Standard timestamp: "2002-08-28T15:30:00+0300"
13-digit Epoch: 1030545000000
$endDate
accepted date values
ISO 8601 Standard date: "2002-08-28"
ISO 8601 Standard timestamp: "2002-08-28T15:30:00+0300"
13-digit Epoch: 1030545000000
Examples:
[date.between(document.first_publication_date, "2017-01-16", "2017-01-20")]
[date.between(document.last_publication_date, "2016-09-15T05:30:00+0100", "2017-10-15T11:45:00+0100")]
[date.between(my.query-fields.date, 1483074000000, 1483333200000)]
The date.day-of-month predicate checks that the value in the path is equal to the day of the month passed into the predicate.
[date.day-of-month( $path, $day )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$day
integer
Day of the month
Examples:
[date.day-of-month(document.first_publication_date, 22)]
[date.day-of-month(document.last_publication_date, 30)]
[date.day-of-month(my.post.date, 14)]
The date.day-of-month-after predicate checks that the value in the path is after the day of the month passed into the predicate.
Note that this will return only the days after the specified day of the month. It will not return any documents where the day is equal to the specified day.
[date.day-of-month-after( $path, $day )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$day
integer
Day of the month
Examples:
[date.day-of-month-after(document.first_publication_date, 22)]
[date.day-of-month-after(document.last_publication_date, 10)]
[date.day-of-month-after(my.event.date-and-time, 15)]
The date.day-of-month-before predicate checks that the value in the path is before the day of the month passed into the predicate.
Note that this will return only the days before the specified day of the month. It will not return any documents where the date is equal to the specified day.
[date.day-of-month-before( $path, $day )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$day
integer
Day of the month
Examples:
[date.day-of-month-before(document.first_publication_date, 20)]
[date.day-of-month-before(document.last_publication_date, 10)]
[date.day-of-month-before(my.blog-post.release-date, 23)]
The date.day-of-week predicate checks that the value in the path is equal to the day of the week passed into the predicate.
[date.day-of-week( $path, $day )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$day
string* or integer
'monday', 'mon', or 1
'tuesday', 'tue', or 2
'wednesday', 'wed', or 3
'thursday', 'thu', or 4
'friday', 'fri', or 5
'saturday', 'sat', or 6
'sunday', 'sun', or 7
* For any of the string input values you can use either first letter capitalized, all lowercase, or all uppercase. For example, "Monday", "monday", and "MONDAY" are all accepted values.
Examples:
[date.day-of-week(document.first_publication_date, "monday")]
[date.day-of-week(document.last_publication_date, "sun")]
[date.day-of-week(my.concert.show-date, "Friday")]
The date.day-of-week-after predicate checks that the value in the path is after the day of the week passed into the predicate.
This predicate uses Monday as the beginning of the week:
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
- Saturday
- Sunday
Note that this will return only the days after the specified day of the week. It will not return any documents where the day is equal to the specified day.
[date.day-of-week-after( $path, $day )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$day
string* or integer
'monday', 'mon', or 1
'tuesday', 'tue', or 2
'wednesday', 'wed', or 3
'thursday', 'thu', or 4
'friday', 'fri', or 5
'saturday', 'sat', or 6
'sunday', 'sun', or 7
* For any of the string input values you can use either first letter capitalized, all lowercase, or all uppercase. For example, "Monday", "monday", and "MONDAY" are all accepted values.
Examples:
[date.day-of-week-after(document.first_publication_date, "fri")]
[date.day-of-week-after(document.last_publication_date, "Thu")]
[date.day-of-week-after(my.blog-post.date, "tuesday")]
The date.day-of-week-before predicate checks that the value in the path is before the day of the week passed into the predicate.
This predicate uses Monday as the beginning of the week:
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
- Saturday
- Sunday
Note that this will return only the days before the specified day of the week. It will not return any documents where the day is equal to the specified day.
[date.day-of-week-before( $path, $day )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$day
string* or integer
'monday', 'mon', or 1
'tuesday', 'tue', or 2
'wednesday', 'wed', or 3
'thursday', 'thu', or 4
'friday', 'fri', or 5
'saturday', 'sat', or 6
'sunday', 'sun', or 7
* For any of the string input values you can use either first letter capitalized, all lowercase, or all uppercase. For example, "Monday", "monday", and "MONDAY" are all accepted values.
Examples:
[date.day-of-week-before(document.first_publication_date, "Wed")]
[date.day-of-week-before(document.last_publication_date, "saturday")]
[date.day-of-week-before(my.page.release-date, "Saturday")]
The date.month predicate checks that the value in the path occurs in the month value passed into the predicate.
[date.month( $path, $month )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$month
string* or integer
'january', 'jan', or 1
'february', 'feb', or 2
'march', 'mar', or 3
'april', 'apr', or 4
'may' or 5
'june', 'jun', or 6
'july', 'jul', or 7
'august', 'aug', or 8
'september', 'sep', or 9
'october', 'oct', or 10
'november', 'nov', or 11
'december', 'dec', or 12
* For any of the string input values you can use either first letter capitalized, all lowercase, or all uppercase. For example, "January", "january", and "JANUARY" are all accepted values.
Examples:
[date.month(document.first_publication_date, "august")]
[date.month(document.last_publication_date, "Sep")]
[date.month(my.blog-post.date, 1)]
The date.month-after predicate checks that the value in the path occurs in any month after the value passed into the predicate.
Note that this will only return documents where the date is after the specified month. It will not return any documents where the date is within the specified month.
[date.month-after( $path, $month )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$month
string* or integer
'january', 'jan', or 1
'february', 'feb', or 2
'march', 'mar', or 3
'april', 'apr', or 4
'may' or 5
'june', 'jun', or 6
'july', 'jul', or 7
'august', 'aug', or 8
'september', 'sep', or 9
'october', 'oct', or 10
'november', 'nov', or 11
'december', 'dec', or 12
* For any of the string input values you can use either first letter capitalized, all lowercase, or all uppercase. For example, "January", "january", and "JANUARY" are all accepted values.
Examples:
[date.month-after(document.first_publication_date, "February")]
[date.month-after(document.last_publication_date, 6)]
[date.month-after(my.article.date, "oct")]
The date.month-before predicate checks that the value in the path occurs in any month before the value passed into the predicate.
Note that this will only return documents where the date is before the specified month. It will not return any documents where the date is within the specified month.
[date.month-before( $path, $month )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$month
string* or integer
'january', 'jan', or 1
'february', 'feb', or 2
'march', 'mar', or 3
'april', 'apr', or 4
'may' or 5
'june', 'jun', or 6
'july', 'jul', or 7
'august', 'aug', or 8
'september', 'sep', or 9
'october', 'oct', or 10
'november', 'nov', or 11
'december', 'dec', or 12
* For any of the string input values you can use either first letter capitalized, all lowercase, or all uppercase. For example, "January", "january", and "JANUARY" are all accepted values.
Examples:
[date.month-before(document.first_publication_date, 8)]
[date.month-before(document.last_publication_date, "june")]
[date.month-before(my.blog-post.release-date, "Sep")]
The date.year predicate checks that the value in the path occurs in the year value passed into the predicate.
[date.year( $path, $year )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$year
integer
Year
Examples:
[date.year(document.first_publication_date, 2016)]
[date.year(document.last_publication_date, 2017)]
[date.year(my.employee.birthday, 1986)]
The date.hour predicate checks that the value in the path occurs within the hour value passed into the predicate.
This uses the 24 hour system, starting at 0 and going through 23.
Note that this predicate will technically work for a Date field, but won’t be very useful. All date field values are automatically given an hour of 0.
[date.hour( $path, $hour )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$hour
integer
Hour between 0 and 23
Examples:
[date.hour(document.first_publication_date, 12)]
[date.hour(document.last_publication_date, 8)]
[date.hour(my.event.date-and-time, 19)]
The date.hour-after predicate checks that the value in the path occurs after the hour value passed into the predicate.
This uses the 24 hour system, starting at 0 and going through 23.
Note that this will only return documents where the timestamp is after the specified hour. It will not return any documents where the timestamp is within the specified hour.
This predicate will technically work for a Date field, but won’t be very useful. All date field values are automatically given an hour of 0.
[date.hour-after( $path, $hour )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$hour
integer
Hour between 0 and 23
Examples:
[date.hour-after(document.first_publication_date, 21)]
[date.hour-after(document.last_publication_date, 8)]
[date.hour-after(my.blog-post.releaseDate, 16)]
The date.hour-before predicate checks that the value in the path occurs before the hour value passed into the predicate.
This uses the 24 hour system, starting at 0 and going through 23.
Note that this will only return documents where the timestamp is before the specified hour. It will not return any documents where the timestamp is within the specified hour.
This predicate will technically work for a Date field, but won’t be very useful. All date field values are automatically given an hour of 0.
[date.hour-before( $path, $hour )]
$path
accepted paths
document.first_publication_date
document.last_publication_date
my.{custom-type}.{field}
$hour
integer
Hour between 0 and 23
Examples:
[date.hour-before(document.first_publication_date, 10)]
[date.hour-before(document.last_publication_date, 12)]
[date.hour-before(my.event.dateAndTime, 12)]