SQLFormatter
FormatterConvertPricingDocsGet Pro
SQL Converter · PostgreSQLRedshift

Convert PostgreSQL SQL to Redshift

PostgreSQL to Redshift swaps interval math for DATEADD, now() for GETDATE() and STRING_AGG for LISTAGG. A mechanical formatter only re-indents — it won’t rewrite dialect-specific syntax. The AI converter in the app translates the query and the table below shows exactly what changes.

PostgreSQL — source
PostgreSQL
SELECT date_trunc('day', o.created_at) AS d,
       STRING_AGG(o.code, ',') AS codes
FROM orders o
WHERE o.created_at > now() - INTERVAL '30 days'
GROUP BY 1;
Redshift — converted
Redshift
SELECT DATE_TRUNC('day', o.created_at) AS d,
       LISTAGG(o.code, ',') WITHIN GROUP (ORDER BY o.code) AS codes
FROM orders o
WHERE o.created_at > DATEADD(DAY, -30, GETDATE())
GROUP BY 1;
Convert your own query

What changes from PostgreSQL to Redshift

PostgreSQLRedshiftWhy
STRING_AGG(x, ',')LISTAGG(x, ',') WITHIN GROUPRedshift uses LISTAGG with an explicit WITHIN GROUP order.
now() - INTERVAL '30 days'DATEADD(DAY, -30, GETDATE())Redshift prefers DATEADD for date math.

Other SQL conversions

PostgreSQLMySQLPostgreSQLT-SQLPostgreSQLBigQueryPostgreSQLSnowflakeAll conversions →