I am attaching my model, query and error screensho...
# orm-help
a
I am attaching my model, query and error screenshot. Can anyone please tell me how to resolve it?
1
l
You pass the date as a string while it is required to be a Date object?
a
I'm not positive here but have you tried
Copy code
where: {
  calendar_date: {
    equals: dayjs(new Date()).format("YYYY-MM-DD),
  }
}
a
@Lars Ivar Igesund yeah i know it’s a date object but look at my model I am putting
@db.Date
so it’ll store the date only now if I pass
new Date()
in query it will include time also so will not match with any record
@alexwasik yes that’s what I did
This is my database records for employee_calendar
l
Your error message quite clearly says "Provided String, expected Date*"
a
@Lars Ivar Igesund I know but how can I pass date without time I tried
new Date()
instead of
dayjs(new Date()).format("YYYY-MM-DD")
in where condition but ended up with no record
cause if you look into database screenshot
calendar_date
only contains date and new Date() has time in it also
l
Probably you can just pass new Date(), if not you should be able to do (new Date()).setHours(0,0,0)
a
@Lars Ivar Igesund okay thanks
a
Can you pass an unformatted Date to the Table? What would that result be?
https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#examples-41 I know you said you tried
equals
. Just saw this and wanted to share
a
I solved it I am passing it like
new Date(dayjs(new Date()).format("YYYY-MM-DD")
)`
a
🎉