Prismic query predicates misinterpreting timestamp field type

I am trying to query my data using my custom field of type Timestamp (created using Slicemachine). I can see that field is also defined as type Timestamp in index.json under /customtypes/mycustomtype/.

      "end_date": {
        "type": "Timestamp",
        "config": {
          "label": "End date",
          "placeholder": ""
        }
      }

However when I try to create a query with dateAfter predicate I am getting an error.

Query:

 const events = await client.getAllByType('event', {
        predicates : [
            prismic.predicate.dateAfter("document.data.end_date", new Date()) 
        ]
}

error message:

error - ParsingError: [function date.after(..)] 'Date' or 'Timestamp' field expected on line:1 col:14 in query '[[date.after(document.data.end_date, 1677426405339)]]'
[[date.after(document.data.end_date, 1677426405339)]]
             ^

Out of curiousity I tried to rewrite the same query and use the Prismic document built in field document.last_publication_date - this time, the query predicate worked as expected.

Any idea why the custom type field data types are not being interpreted correctly? Any help is appreciated.

Hey @peter.siman, I think the query has a small syntax error. Say your Custom type is named Page. Instead of document.data.end_date you need to add my.page.end_date. The other option is used when querying with metadata date fields: first_publication_date and last_publication_date

Check out the REST API documentation to learn more about date predicates

1 Like

Hi @Pau, thanks for your reply. This seems to have fixed the issue. It was probably my misunderstanding of the query syntax.

1 Like