Formatting date_of_birth as MM-DD-YYYY

What's the best way of doing this? date_of_birth: varchar("date_of_birth", { length: 10 }).notNull() That's what I have so far, but I need it to be MM-DD-YYYY. It needs to be this way because of the API I need to sync with.
import { pgTable, serial, timestamp, varchar } from "drizzle-orm/pg-core"
import { createInsertSchema } from "drizzle-zod"
import type { z } from "zod"

export const users = pgTable("users", {
id: serial("id").primaryKey(),
email: varchar("email", { length: 255 }).notNull(),
phone: varchar("phone", { length: 10 }).notNull(),
first_name: varchar("first_name", { length: 255 }).notNull(),
middle_name: varchar("middle_name", { length: 255 }),
last_name: varchar("last_name", { length: 255 }).notNull(),
gender: varchar("gender", {
enum: ["male", "female", "other"],
}),
gender_biological: varchar("gender_biological", {
enum: ["male", "female"],
}).notNull(),
date_of_birth: varchar("date_of_birth", { length: 10 }).notNull(),
})

export const insertUserSchema = createInsertSchema(users)
export type User = z.infer<typeof insertUserSchema>
import { pgTable, serial, timestamp, varchar } from "drizzle-orm/pg-core"
import { createInsertSchema } from "drizzle-zod"
import type { z } from "zod"

export const users = pgTable("users", {
id: serial("id").primaryKey(),
email: varchar("email", { length: 255 }).notNull(),
phone: varchar("phone", { length: 10 }).notNull(),
first_name: varchar("first_name", { length: 255 }).notNull(),
middle_name: varchar("middle_name", { length: 255 }),
last_name: varchar("last_name", { length: 255 }).notNull(),
gender: varchar("gender", {
enum: ["male", "female", "other"],
}),
gender_biological: varchar("gender_biological", {
enum: ["male", "female"],
}).notNull(),
date_of_birth: varchar("date_of_birth", { length: 10 }).notNull(),
})

export const insertUserSchema = createInsertSchema(users)
export type User = z.infer<typeof insertUserSchema>
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server