Hey! This content applies only to previous CARTO products

Please check if it's relevant to your use case. On October 2021 we released a new version of our platform.
You can learn more and read the latest documentation at docs.carto.com

Questions  /  Working with Data  /  SQL

How can I combine several string values/columns and convert them into a date?

Learn how to combine and convert several column values into a data with a PostgreSQL function.

In order to combine two or more string column or values and convert them into a date, it would be necessary to apply a SQL query similar to this one, thus using to_timestamp PostgreSQL function:

SELECT
  *,
   to_timestamp(date_col || ' ' || hour_col, 'DD-MM-YYYY HH24-MI-SS') as date
FROM
  table