Convert a text expression into a proper DATE value using ParadeDB’s PostgreSQL-compatible functions.
Storing dates as DATE ensures proper sorting, filtering, and indexing. ParadeDB inherits PostgreSQL’s robust date functions, so conversion unlocks these features.
Use the built-in TO_DATE(text, format)
or an explicit ::DATE
cast when the ISO-8601 layout is already respected.
Choose TO_DATE
when the incoming string is not ISO-formatted (e.g., ‘07/25/2024’).Use a cast for ‘2024-07-25’ strings, which PostgreSQL parses automatically.
See the dedicated syntax block below. Note the mandatory format
mask for TO_DATE
.
Insert raw CSV data into a staging table, then convert the text column with TO_DATE
during the final insert into Orders
.
Yes. Use ALTER TABLE ... ALTER COLUMN ... TYPE DATE USING TO_DATE(...)
.This rewrites the table in place.
Wrap conversions in a transaction and validate with a SELECT
first. ParadeDB’s planner handles set-based operations efficiently.
Validate format masks with SELECT TO_DATE('2024-13-01','YYYY-MM-DD');
—it raises an error for invalid months. Index DATE columns after conversion for faster range queries.
Review the section below to avoid silent data issues.
.
Yes. ParadeDB builds on PostgreSQL, so every format pattern (e.g., YYYY, MM, DD, FM) works the same.
Use ALTER TABLE ... ALTER COLUMN ... TYPE DATE USING ...
inside a transaction during low-traffic windows. ParadeDB will lock writes but keeps reads available with minimal interruption.