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?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityWhat 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: