SYSDATETIMEOFFSET Function - SQL Server to PostgreSQL Migration

In SQL Server, the SYSDATETIMEOFFSET function returns the current date and time with 100 nanoseconds precision with the time zone of the current database instance.

In PostgreSQL you can use the NOW function that also includes time zone.

SQL Server:

  -- Get the current datetime with time zone
  SELECT SYSDATETIMEOFFSET();
  /* 2024-12-11 12:38:31.3759175 +01:00 */

PostgreSQL:

  -- Get the current datetime with time zone
  SELECT NOW();
  /* 2024-12-11 12:38:31.375917+01 */

For more information, see SQL Server to PostgreSQL Migration.