shahrukh ahmed
07/14/2022, 9:58 AMAlex Ruheni
gte
and lte
filters to query DateTime
values.
Assuming you have the following schema:
model Post {
id String @id @default(cuid())
title String
createdAt DateTime @default(now())
}
You could filter the postβs createdAt
field as follows:
await prisma.post.findMany({
where: {
createdAt: {
gte: new Date(/** range start */).toISOString(),
lte: new Date(/** range end */).toISOString(),
}
}
})
shahrukh ahmed
07/14/2022, 11:34 AMAlex Ruheni
new Date('2020 June 14').toISOString()
is: '2020-06-13T21:00:00.000Z'
shahrukh ahmed
07/14/2022, 11:41 AMshahrukh ahmed
07/14/2022, 11:41 AMAlex Ruheni
shahrukh ahmed
07/14/2022, 11:50 AMAlex Ruheni
shahrukh ahmed
07/14/2022, 11:57 AM