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 prismic.io and React.

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.

dateAfter

The dateAfter 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.

Copy
Prismic.Predicates.dateAfter( path, date )

path

accepted paths

document.first_publication_date

document.last_publication_date

my.{custom-type}.{field}

date

accepted date values

Date object

String in the following format: "YYYY-MM-DD"

Examples:

Copy
Prismic.Predicates.dateAfter('document.first_publication_date', new Date('2017-05-18'))
Prismic.Predicates.dateAfter('document.last_publication_date', '2017-05-18')
Prismic.Predicates.dateAfter('my.article.release_date', '2017-01-22')

dateBefore

The dateBefore 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.

Copy
Prismic.Predicates.dateBefore( path, date )

path

accepted paths

document.first_publication_date

document.last_publication_date

my.{custom-type}.{field}

date

accepted date values

Date object

String in the following format: "YYYY-MM-DD"

Examples:

Copy
Prismic.Predicates.dateBefore('document.first_publication_date', '2016-09-19')
Prismic.Predicates.dateBefore('document.last_publication_date', new Date('2016-10-15'))
Prismic.Predicates.dateBefore('my.post.date', new Date('2017-08-24'))

dateBetween

The dateBetween predicate checks that the value in the path is within the date values passed into the predicate.

Copy
Prismic.Predicates.dateBetween( path, startDate, endDate )

path

accepted paths

document.first_publication_date

document.last_publication_date

my.{custom-type}.{field}

startDate

accepted date values

Date object

String in the following format: "YYYY-MM-DD"

endDate

accepted date values

Date object

String in the following format: "YYYY-MM-DD"

Examples:

Copy
Prismic.Predicates.dateBetween('document.first_publication_date', '2017-01-16', '2017-01-20')
Prismic.Predicates.dateBetween('document.last_publication_date', new Date('2017-01-16'), new Date('2017-01-20'))
Prismic.Predicates.dateBetween('my.blog_post.post_date', '2017-01-16', '2017-01-20')

dayOfMonth

The dayOfMonth predicate checks that the value in the path is equal to the day of the month passed into the predicate.

Copy
Prismic.Predicates.dayOfMonth( path, day )

path

accepted paths

document.first_publication_date

document.last_publication_date

my.{custom-type}.{field}

day

integer

Day of the month

Examples:

Copy
Prismic.Predicates.dayOfMonth('document.first_publication_date', 22)
Prismic.Predicates.dayOfMonth('document.last_publication_date', 30)
Prismic.Predicates.dayOfMonth('my.post.date', 14)

dayOfMonthAfter

The dayOfMonthAfter 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.

Copy
Prismic.Predicates.dayOfMonthAfter( path, day )

path

accepted paths

document.first_publication_date

document.last_publication_date

my.{custom-type}.{field}

day

integer

Day of the month

Examples:

Copy
Prismic.Predicates.dayOfMonthAfter('document.first_publication_date', 1)
Prismic.Predicates.dayOfMonthAfter('document.last_publication_date', 10)
Prismic.Predicates.dayOfMonthAfter('my.event.date_and_time', 15)

dayOfMonthBefore

The dayOfMonthBefore 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.

Copy
Prismic.Predicates.dayOfMonthBefore( path, day )

path

accepted paths

document.first_publication_date

document.last_publication_date

my.{custom-type}.{field}

day

integer

Day of the month

Examples:

Copy
Prismic.Predicates.dayOfMonthBefore('document.first_publication_date', 30)
Prismic.Predicates.dayOfMonthBefore('document.last_publication_date', 10)
Prismic.Predicates.dayOfMonthBefore('my.blog_post.release_date', 23)

dayOfWeek

The dayOfWeek predicate checks that the value in the path is equal to the day of the week passed into the predicate.

Copy
Prismic.Predicates.dayOfWeek( path, weekDay )

path

accepted paths

document.first_publication_date

document.last_publication_date

my.{custom-type}.{field}

weekDay

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:

Copy
Prismic.Predicates.dayOfWeek('document.first_publication_date', 'monday')
Prismic.Predicates.dayOfWeek('document.last_publication_date', 'sunday')
Prismic.Predicates.dayOfWeek('my.concert.show_date', 'Friday')

dayOfWeekAfter

The dayOfWeekAfter 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:

  1. Monday
  2. Tuesday
  3. Wednesday
  4. Thursday
  5. Friday
  6. Saturday
  7. 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.

Copy
Prismic.Predicates.dayOfWeekAfter( path, weekDay )

path

accepted paths

document.first_publication_date

document.last_publication_date

my.{custom-type}.{field}

weekDay

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:

Copy
Prismic.Predicates.dayOfWeekAfter('document.first_publication_date', 'friday')
Prismic.Predicates.dayOfWeekAfter('document.last_publication_date', 'Thursday')
Prismic.Predicates.dayOfWeekAfter('my.blog_post.date', 'tuesday')

dayOfWeekBefore

The dayOfWeekBefore 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:

  1. Monday
  2. Tuesday
  3. Wednesday
  4. Thursday
  5. Friday
  6. Saturday
  7. 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

Copy
Prismic.Predicates.dayOfWeekBefore( path, weekDay )

path

accepted paths

document.first_publication_date

document.last_publication_date

my.{custom-type}.{field}

weekDay

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:

Copy
Prismic.Predicates.dayOfWeekBefore('document.first_publication_date', 'Wednesday')
Prismic.Predicates.dayOfWeekBefore('document.last_publication_date', 'saturday')
Prismic.Predicates.dayOfWeekBefore('my.page.release_date', 'Saturday')

month

The month predicate checks that the value in the path occurs in the month value passed into the predicate.

Copy
Prismic.Predicates.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:

Copy
Prismic.Predicates.month('document.first_publication_date', 'august')
Prismic.Predicates.month('document.last_publication_date', 'Sep')
Prismic.Predicates.month('my.blog_post.date', 1)

monthAfter

The monthAfter 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.

Copy
Prismic.Predicates.monthAfter( 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:

Copy
Prismic.Predicates.monthAfter('document.first_publication_date', 'February')
Prismic.Predicates.monthAfter('document.last_publication_date', 6)
Prismic.Predicates.monthAfter('my.article.date', 'oct')

monthBefore

The monthBefore 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.

Copy
Prismic.Predicates.monthBefore( 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:

Copy
Prismic.Predicates.monthBefore('document.first_publication_date', 8)
Prismic.Predicates.monthBefore('document.last_publication_date', 'june')
Prismic.Predicates.monthBefore('my.blog_post.release_date', 'Sep')

year

The year predicate checks that the value in the path occurs in the year value passed into the predicate.

Copy
Prismic.Predicates.year( path, year )

path

accepted paths

document.first_publication_date

document.last_publication_date

my.{custom-type}.{field}

year

integer

Year

Examples:

Copy
Prismic.Predicates.year('document.first_publication_date', 2016)
Prismic.Predicates.year('document.last_publication_date', 2017)
Prismic.Predicates.year('my.employee.birthday', 1986)

hour

The 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.

Copy
Prismic.Predicates.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:

Copy
Prismic.Predicates.hour('document.first_publication_date', 12)
Prismic.Predicates.hour('document.last_publication_date', 8)
Prismic.Predicates.hour('my.event.date_and_time', 19)

hourAfter

The hourAfter 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.

Copy
Prismic.Predicates.hourAfter( 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:

Copy
Prismic.Predicates.hourAfter('document.first_publication_date', 21)
Prismic.Predicates.hourAfter('document.last_publication_date', 8)
Prismic.Predicates.hourAfter('my.blog_post.release_date', 16)

hourBefore

The hourBefore 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.

Copy
Prismic.Predicates.hourBefore( 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:

Copy
Prismic.Predicates.hourBefore('document.first_publication_date', 10)
Prismic.Predicates.hourBefore('document.last_publication_date', 12)
Prismic.Predicates.hourBefore('my.event.date_and_time', 12)