PostgreSQL query TO_TIMESTAMP

Maybe understanding PostgreSQL’s TO_TIMESTAMP() function might be helpful.

Try this article: PostgreSQL TO_TIMESTAMP() Function By Practical Examples (postgresqltutorial.com).

From that article:

The following statement uses the TO_TIMESTAMP() function to convert a string to a timestamp:

SELECT TO_TIMESTAMP(
    '2017-03-31 9:30:20',
    'YYYY-MM-DD HH:MI:SS'
);

Output:

to_timestamp
------------------------
 2017-03-31 09:30:20-07
(1 row)

In this example:

  • YYYY is the four-digit year 2017
  • MM is the month 03
  • DD is the day 31
  • HH is the hour 9
  • MI is the minute 30
  • SS is the second 20