Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Filter within a given date #419

Closed
impowski opened this issue Jan 13, 2020 · 1 comment
Closed

Filter within a given date #419

impowski opened this issue Jan 13, 2020 · 1 comment
Labels
kind/feature A request for a new feature.

Comments

@impowski
Copy link

In previous versions of Prisma we could pass this 2020-01-01 inside a resolver if we had a DateTime type and then use it to query items from database.

I'll provide an example of what I want to be able to do.

So suppose we have many different rows inside our table, which has a createdAt column. There is multiple rows which have the same date of creation but the time is different, like so 2020-01-01T21:00:00, 2020-01-01T00:00:00 and so on. If I'll pass 2020-01-01 I'll get all of those rows which have a 2020-01-01 as a date. Besides that it would be nice to be able to pass an array of dates like so [2020-01-01, 2020-01-02] and use it inside in parameter so it would return all of the rows within those days with all possible time values.

I hope this is a clear explanation. Would like to hear some comments on that.

@pantharshit00 pantharshit00 transferred this issue from prisma/prisma Jan 17, 2020
@pantharshit00 pantharshit00 added the kind/feature A request for a new feature. label Jan 17, 2020
@matthewmueller matthewmueller added the process/candidate Candidate for next Milestone. label Jul 8, 2020
@thebiglabasky thebiglabasky removed the process/candidate Candidate for next Milestone. label Jul 8, 2020
@matthewmueller
Copy link
Contributor

This is already possible, though not as a string:

  const data = await client.post.findMany({
    where: {
      createdAt: {
        gte: new Date("2020-01-01"),
        lt:  new Date("2020-01-02")
      },
    },
  });

We only support ISO formatted timestamps as string inputs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature A request for a new feature.
Projects
None yet
Development

No branches or pull requests

4 participants