PostgreSQL make_date() Function
The PostgreSQL make_date()
function creates a date from the given year, month, and day fields.
make_date()
Syntax
Here is the syntax of the PostgreSQL make_date()
function:
make_date(year INT, month INT, day INT) -> DATE
Parameters
year
-
Required. An integer indicating the year.
month
-
Required. An integer indicating the month.
day
-
Required. An integer indicating the day of the month.
Return value
The PostgreSQL make_date()
function returns a date value created from the given year, month, and day fields.
If the year is negative, it means the date is in BC.
make_date()
Examples
Here are a few examples showing the basic usage of the make_date()
function.
SELECT make_date(2022, 5, 15);
make_date
------------
2022-05-15
You can also create a BC date by supplying a negative number for the year:
SELECT make_date(-2022, 5, 15);
make_date
---------------
2022-05-15 BC