GETDATE Function - SQL Server to PostgreSQL Migration

In SQL Server the GETDATE function returns the current date and time with milliseconds precision without the time zone for the current database instance.

In PostgreSQL you can use the NOW function but it includes time zone.

SQL Server:

  -- Get the current date and time with milliseconds precision
  SELECT GETDATE();
  # 2024-07-28 13:13:11.640

PostgreSQL:

  -- Get the current date and time
  SELECT NOW();
  # 2024-07-28 13:13:11.640768+03

For more information, see SQL Server to PostgreSQL Migration.