Hey guys how can i search between iso dates? ```da...
# orm-help
j
Hey guys how can i search between iso dates?
Copy code
dataini: {  equals: "2006-01-23T19:00:00.000Z" }
if I do this it works but if I want only to specify a date like this 2006-01-23 it doesnt return nothing....
1
t
Hey Joao, You can do something like this to filter a certain date. This example will find all posts that are created at 2020-01-01.
Copy code
const data = await client.post.findMany({
    where: {
      createdAt: {
        gte: new Date("2020-01-01"),
        lt:  new Date("2020-01-02")
      },
    },
  });
j
Hi Tasin, thank you for your time... Sorry I should have clarified that i've tried that, the problem is that if I dont put the exact hour after the T he doesnt return nothing.... In the example I have 2006-01-23T190000.000Z but if I put like you say it passes 2006-01-23T000000.000Z then it doesnt find it becouse its not 19:00 hours...
Maybe its some problem in the db I've tried this in a new bd and it works... thx 🙂
t
Oh glad it got resolved! But just to clarify, if you want to query by a single day (like 2006-01-23) or any other time frame, instead of a very specific time (like 2006-01-23T190000.000Z) you need to use a combination of
gt/gte
and
lt/lte
.
👍 1