What is the equivalent of the Postgres "current_timestamp at time zone 'UTC'" in SQL Server?
How do I select the current timestamp in UTC in SQL Server?
What you're looking for is the SYSUTCDATETIME
function, which is used like this:
SELECT SYSUTCDATETIME();
It returns the current system date and time, adjusted to UTC time.
This seems similar to what the postgres equivalent does (except it looks like current_timestamp
includes timezone information, while SYSUTCDATETIME
does not).
If you need the time zone information, you can use a similar construction in SQL Server with the SYSDATETIMEOFFSET
function:
SELECT SYSDATETIMEOFFSET() AT TIME ZONE 'UTC';
The results look like this:
GETUTCDATE()
also works if don't require as much fractional second precision. learn.microsoft.com/en-us/sql/t-sql/functions/…