2

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?

0

1 Answer 1

3

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:

Screenshot of the results of calling the above-mentioned system functions, showing the results are the same with the exception that sysdatetimeoffset includes the time zone offset

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.