Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda