hi, guys, I'm having trouble creating the yyyy-mm-...
# orm-help
b
hi, guys, I'm having trouble creating the yyyy-mm-dd date format in PG, can anyone help me? model Subscription { id String @id @default(uuid()) @db.VarChar(250) idPlan String @db.VarChar(250) plan Plan @relation(_fields_: [idPlan], _references_: [id]) //relacionamento idClient String priceAll Decimal @db.Decimal(10, 2) status Boolean paymentMethod String startDate DateTime @db.Date finishDate DateTime @db.Date } Argument finishDate: Got invalid value '2023-02-20' on prisma.createOneSubscription. Provided String, expected DateTime or Null. Argument startDate: Got invalid value '2022-02-20' on prisma.createOneSubscription. Provided String, expected DateTime or Null.
r
Olá can you show the query that results in that error?
b
ok Ruben, você fala portugues?
const subscription = await prismaClient.subscription.create({ data: { finishDate, //format (YYYY-MM-DD) startDate, //format (YYYY-MM-DD) status, priceAll, idClient, paymentMethod, idPlan // SubscriptionPlugin: { // createMany: { // data: [ // idProduct // ] // } // } }, }) return { subscription }
r
I do speak Portuguese, but that's probably against the rules of this slack. the Subscription expects a Date type for
startDate
and
finishDate
, I believe you can do:
Copy code
data: {
  finishDate: new Date(finishDate),
  startDate: new Date(startDate),
  status,
  ...
}
to convert those date strings to date objects
b
I decided to change the date field to string format thank's
r
👍
b
Ruben, I tried it this way and it worked! thanks
r
Glad to hear it 🙂