is there any workaround for prisma to handle dates...
# orm-help
т
is there any workaround for prisma to handle dates such as 000-00-00 via custom scalars, having a simple date crush your production env is far from ideal
m
Hey @Тоше are there any issues with doing:
Copy code
prisma.user.create({
  data: {
    created_at: new Date("0000-00-00")
  }
})
?
т
Example if we have a date where the day or the month is being set to 0, and i try to fetch it from the db
Copy code
findMany()` invocation:\n\n\n  Value out of range for the type. The column `DOB` contained an invalid datetime value with either day or month set to zero.",
this error is being thrown which kills the current query. Tried overriding it with a custom scalar that would return null in this case, but no luck. Its a specific case with mysql/mariadb supporting this dates
m
Interesting, does MySQL/MariaDB support fields with 0th days and months?
Probably best to create an issue: https://github.com/prisma/prisma/issues with a reproduction so we don't lose track of it. I'd like to learn more about your use case. We're weary of adding more date formats as strings since often you can use new Date() or libraries like momentjs to do fancy formats. But for your specific case of having 0th data in the database and you're having issues querying it, that'd be worth looking into.
т
Mariadb supports this 00 dates as a special case where no date is present, for example if u where to insert an empty string into a datetime field in mariadb it would revert to this date. Which overtime for older architectures is a massive problem for migrating into prisma. https://mariadb.com/kb/en/datetime/#:~:text=MariaDB%20also%20supports%20'%200000%2D00,is%20specified%20in%20the%20SQL_MODE.