Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTime without time / only data? It is possible in Prisma?

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
like image 523
mxcdh Avatar asked Jan 21 '26 14:01

mxcdh


1 Answers

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

like image 57
Nurul Sundarani Avatar answered Jan 24 '26 11:01

Nurul Sundarani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!