'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


Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nurul Sundarani