PostgreSQL → SQL Server

Fixing 'NOW() is not a recognized built-in function name' in SQL Server

NOW() is PostgreSQL. In SQL Server use GETDATE(), SYSDATETIME(), or CURRENT_TIMESTAMP.

When moving queries from PostgreSQL to SQL Server, NOW() fails immediately. T-SQL does not recognize that function — the closest equivalent is GETDATE() or SYSDATETIME() for higher precision.

Direct replacement

PostgreSQL

INSERT INTO events (ts) VALUES (NOW());

SQL Server

INSERT INTO events (ts) VALUES (GETDATE());

Date intervals

PostgreSQL

WHERE created_at >= NOW() - INTERVAL '7 days'

SQL Server

WHERE created_at >= DATEADD(day, -7, GETDATE())

Analisador de Impacto

Translate NOW(), INTERVAL, and Postgres date functions to T-SQL in one click — paste the snippet below.

Abrir Análise de Projeto →