How to save partial dates with prisma? Prisma supp...
# prisma-client
s
How to save partial dates with prisma? Prisma supports ISO 8601 which in theory supports it. When only saving a year ‘2021’ I am seeing the following error:
Copy code
Argument started: Got invalid value '2021' on [...]. Provided String, expected DateTime or NullableDateTimeFieldUpdateOperationsInput or Null.
Is it possible to save say ‘2021’ in a date field and then also query it?
r
@sven 👋 Just setting the year on the date should make it work. You would need to always pass a date object/string though.
s
👋 When reading the date it will return a full date though (’2021-01-01…’) right?
I am playing around with a precision column, right now.
r
So you would only work with the year part of the date?
s
year, or year and month, or full date
2021
or
2021-11
or
2021-11-02
r
Storing these values would be fine, but granular querying would only be possible using a raw query as Prisma compares the whole timestamp and not just the date
s
okay. thanks. I am doing it with a raw query
👍 1