Turning a text value into a real DATE you can do math on.
ISO format (‘2024-01-15’)
-- MySQL
SELECT CAST('2024-01-15' AS DATE);
-- PostgreSQL
SELECT '2024-01-15'::date; -- or CAST('2024-01-15' AS DATE)
-- BigQuery
SELECT DATE('2024-01-15');
-- Snowflake
SELECT '2024-01-15'::date; -- or TO_DATE('2024-01-15')
-- SQLite
SELECT DATE('2024-01-15'); -- ISO strings only
-- DuckDB
SELECT DATE '2024-01-15'; -- or '2024-01-15'::DATE
Custom format (e.g. ‘15/01/2024’)
-- MySQL
SELECT STR_TO_DATE('15/01/2024', '%d/%m/%Y');
-- PostgreSQL
SELECT TO_DATE('15/01/2024', 'DD/MM/YYYY');
-- BigQuery
SELECT PARSE_DATE('%d/%m/%Y', '15/01/2024');
-- Snowflake
SELECT TO_DATE('15/01/2024', 'DD/MM/YYYY');
-- DuckDB
SELECT strptime('15/01/2024', '%d/%m/%Y')::DATE;
Gotchas: SQLite has no format parser — it only understands ISO-8601 (YYYY-MM-DD); reformat
the string first (e.g. with substr) or store ISO. Format tokens differ by family: MySQL/BigQuery
use strftime-style (%d/%m/%Y), while Postgres/Snowflake use template patterns (DD/MM/YYYY).
Casting a string with the wrong order (DMY vs MDY) silently gives the wrong date — always pass an
explicit format for non-ISO input.