Hello together I have in a table a date field and...
# orm-help
a
Hello together I have in a table a date field and one which gives the duration in minutes. now I want to read via findmany all entries where the date in the date field + the duration in minutes is greater than the current date. Can anyone of you help me?
n
Hey 👋, Can you share your schema file with the model having date fields? For comparison between dates, you would need Filter Operators like
lt/lte/gt/gte
Here is an example of comparing dates, Considering this Project model
Copy code
model Project {
  id            Int       @id @default(autoincrement())
  title         String
  userId        Int
  dueDate       DateTime?
  completedDate DateTime?
  createdAt     DateTime? @default(now())
}
You could compare dates like this
Copy code
import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

await prisma.project.findMany({
  where: {
    completedDate: {
      lt: Date.now()
    }
  }
})
a
This is the schema:
Copy code
model StageItem {
    id           String          @id @default(uuid())
    start_at     DateTime
    duration     Int
}
And now i want select all records, where the start_at + duration is bigger then a given date.