SQLFormatter
FormatterConvertPricingDocsGet Pro
SQL Converter · RedshiftPostgreSQL

Convert Redshift SQL to PostgreSQL

Redshift to PostgreSQL swaps GETDATE()/DATEADD for now() and intervals, and LISTAGG for STRING_AGG. 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.

Redshift — source
Redshift
SELECT s.user_id,
       LISTAGG(s.event, ',') WITHIN GROUP (ORDER BY s.ts) AS events
FROM sessions s
WHERE s.ts > DATEADD(DAY, -7, GETDATE())
GROUP BY s.user_id;
PostgreSQL — converted
PostgreSQL
SELECT s.user_id,
       STRING_AGG(s.event, ',' ORDER BY s.ts) AS events
FROM sessions s
WHERE s.ts > now() - INTERVAL '7 days'
GROUP BY s.user_id;
Convert your own query

What changes from Redshift to PostgreSQL

RedshiftPostgreSQLWhy
LISTAGG(...) WITHIN GROUPSTRING_AGG(x, ',' ORDER BY ...)Postgres folds the ordering into STRING_AGG.
DATEADD(DAY, -7, GETDATE())now() - INTERVAL '7 days'Date math uses interval literals.
GETDATE()now()Current-timestamp function differs.

Other SQL conversions

OraclePostgreSQLT-SQLPostgreSQLMySQLPostgreSQLAll conversions →