Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Drizzle ORM · Function

date

Drizzle ORM’s MySQL date builder declares a calendar-date column using the SQL date type. Configure its infer mode to expose values as JavaScript Date objects or strings.

How it works

The date column builder declares a MySQL DATE column that stores a calendar date in YYYY-MM-DD form. Its infer mode controls whether Drizzle exposes the value as a JavaScript Date or as the unchanged database string.

Syntax

date(config?)

Parameters

NameTypeDescription
configobjectOptional configuration selecting date or string inference mode.

Returns

A MySQL DATE column builder.

Key points

  • The builder models a calendar date using the YYYY-MM-DD representation.
  • MySQL DATE values documented here span from 1000-01-01 through 9999-12-31.
  • Import date from the MySQL core package and use it inside a mysqlTable definition.
  • The date infer mode makes the column's inferred value a Date.
  • The string infer mode makes the column's inferred value a string.

Common mistakes

  • Choose the infer mode deliberately: date gives Date values, while string leaves values as strings.

Example: Define a MySQL date column

import { date, mysqlTable } from "drizzle-orm/mysql-core";

export const events = mysqlTable("events", {
  eventDate: date({ mode: "date" }),
});

Defines a MySQL DATE column whose inferred TypeScript value is a Date.

When to use it

Store calendar dates

A schema needs a birth date, holiday, or other calendar-only value without a time component.

Infer Date values

Application code should work with JavaScript date objects for a DATE column.

Infer string values

The application must preserve database date strings and handle conversion itself.

Interview questions

QWhat does the Drizzle MySQL date builder represent?

date() creates a MySQL DATE column for calendar dates, with values represented in YYYY-MM-DD format. The builder can infer either a JavaScript Date or a string.

Follow-up: How would you preserve the database representation? Use date({ mode: "string" }), which infers a string value.

QHow do you choose the inferred TypeScript value?

Use date({ mode: "date" }) when the column should be inferred as a JavaScript Date. This is the date-oriented mode shown in the documentation.

Follow-up: What alternative mode is available? date({ mode: "string" }) infers the column as a string instead.

QWhat SQL type and value range does it use?

The generated SQL column type is date, and the documented database range is from 1000-01-01 through 9999-12-31. It represents a calendar date rather than a time-of-day value.

Follow-up: Which database documentation should be consulted for engine-specific details? The MySQL documentation is the referenced authority for this type.

  • mysqlTable
  • timestamp
  • date({ mode: "date" })
  • date({ mode: "string" })

Source: MySQL column types - Drizzle ORM. Checked 2026-10-16.