// dates & times reference

SQL MAKE_DATE function

Returns a date from year, month and day integers. The make_ family is PostgreSQL's constructor set; make_timestamptz also takes a zone.

Category
Dates & times
Returns
date / timestamp
In this category
25 of 121

Syntax

MAKE_DATE(year, month, day)
MAKE_TIMESTAMP(y, m, d, hh, mi, ss)
MAKE_TIMESTAMPTZ(y, m, d, hh, mi, ss, zone)

Each block is a separate form. The support table and the examples show which engine takes which.

Engine support

EngineSupportNotes
SQL Server Different name or syntax DATEFROMPARTS / DATETIMEFROMPARTS
PostgreSQL Yes Supported under this name.
MySQL Different name or syntax MAKEDATE is day-of-year only; no full constructor
SQLite Different name or syntax compose a string for date() or datetime()
Oracle Different name or syntax TO_DATE of a composed string

Examples

PostgreSQL

SELECT make_date(2024, 2, 29) AS leap_day;

PostgreSQL

SELECT make_timestamptz(2024, 1, 15, 9, 30, 0, 'UTC') AS utc_meeting;

SQL Server

SELECT DATEFROMPARTS(2024, 2, 29) AS leap_day;

Good to know

  • Omit the zone on make_timestamptz and PostgreSQL applies the session time zone; the same integers give different instants in different sessions.
  • The whole family validates: month 13 or February 30 raises an error rather than rolling over.
  • SQL Server's DATEFROMPARTS is the name equivalent; MySQL has no full-date constructor: its MAKEDATE counts day-of-year.

Questions about MAKE_DATE

Is make_date the same as DATEFROMPARTS?

Functionally yes: year, month, day in, date out. PostgreSQL names it make_date; SQL Server names it DATEFROMPARTS.

When do I need make_timestamptz?

When the constructed instant must be zone-aware. Passing the zone explicitly beats relying on the session zone, which can differ per connection.

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, SQLite, Oracle.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.