Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
Prisma Query with Date

Suppose I have table in Postgres SQL with prisma.

// Prisma Model

model my_table {
    comment   String   @db.VarChar(255)
    date      DateTime @db.Timestamp(6) // Stored as Now() in sql
}

After insert into my table I have. (the date is stored with no timezone)

// SQL DB Table

| comment  |           date             |
| -------- | -------------------------- |
| Hello    | 2022-08-04 08:16:32.716904 |

I want to query here

// Prisma Query

const rows = await this.prismaClient.my_table.findMany({
     where: {
        date: new Date('2022-08-04T08:16:32.716904')
     },
};

But for some reason I get back no records at all

I have also tried with:


new Date('2022-08-04T08:16:32.716904Z')
new Date('2022-08-04T08:16:32.716Z')
new Date('2022-08-04T08:16:32')
new Date('2022-08-04T08:16:32.716Z').toUTCString()
new Date('2022-08-04T08:16:32.716Z').toISOString()

but none seems to work, any suggestions or help will be appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have tested, but all works fine. I guess, there is no need to convert string to date. Just try to send YY-MM-DD format date

const rows = await this.prismaClient.my_table.findMany({
     where: {
        date: yourDate       // where yourDate=2022-08-20
     },
}

If it won't help, change type of date to @db.Date()

Another way is using raw query with "like" operator

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!