This content applies to a previous version of CARTO
In October 2021 we released a new version of our platform. You can find the latest documentation at docs.carto.com
Back to Help Center
How to Convert Date Data into a String or Numeric Value
Learn how to extract day, month or year values from date columns.
Using to_char for Date to String Conversion
The to_char PostgreSQL function allows users to convert dates (or numbers) into strings:
UPDATE
table_name
SET
date_string = to_char(date_column, 'YYYY-MM-DD')
Using extract for Timestamp Components
The extract function converts temporal data to numeric values while offering specificity by allowing selection of particular timestamp components:
UPDATE
table_name
SET
hour = extract(hour from date_column)
