9

I can in Prisma create columns without data, without time?

my model at the moment:

model modelName {
  id         Int      @id @default(autoincrement())
  createdAt  DateTime @default(now())
  lastNumber Int
}

Actual results:

2 2022-04-19 12:28:04.591+00    45

I want to generate records like this:

2 2022-04-19 45
mxcdh
  • 805
  • 3
  • 10
  • 20

1 Answers1

16

To store only the date portion you could use the native @db.date attribute. That would just store the date and not store the time.

In your schema file you could update the model as below to just store the date portion:

model modelName {
  id         Int      @id @default(autoincrement())
  createdAt  DateTime @default(now()) @db.Date
  lastNumber Int
}

Here's a reference to Prisma's PostgreSQL DateTime attribute: Reference

Nurul Sundarani
  • 5,550
  • 3
  • 23
  • 52