PostgreSQL make_timestamp() Function

The PostgreSQL make_timestamp() function creates a timestamp value from the given year, month, day, hour, minute, and second fields.

make_timestamp() Syntax

Here is the syntax of the PostgreSQL make_timestamp() function:

make_timestamp(
    year INT,
    month INT,
    day INT,
    hour INT,
    minute INT,
    second DOUBLE PRECISION
) -> TIMESTAMP

Parameters

year

Required. An integer indicating the year.

month

Required. An integer indicating the month.

day

Required. An integer indicating the day.

hour

Required. An integer indicating the hour.

minute

Required. An integer indicating the minute.

second

Required. A double-precision floating-point number indicating seconds.

Return value

The PostgreSQL make_timestamp() function returns a timestamp value created from the given year, month, day, hour, minute, and second fields.

If the year is negative, it means the date is in BC.

make_timestamp() Examples

Here are a few examples showing the basic usage of the make_timestamp() function.

SELECT make_timestamp(2022, 5, 15, 20, 55, 25.517606);
       make_timestamp
----------------------------
 2022-05-15 20:55:25.517606

You can also create a BC timestamp value by supplying a negative number for the year:

SELECT make_timestamp(-2022, 5, 15, 20, 55, 25.517606);
        make_timestamp
-------------------------------
 2022-05-15 20:55:25.517606 BC