SYSUTCDATETIME() Examples in SQL Server (T-SQL)

In SQL Server, the T-SQL SYSUTCDATETIME() function is used to return the current UTC time (Coordinated Universal Time). UTC time is the primary time standard by which the world regulates clocks and time.

The return value of the SYSUTCDATETIME() function is derived from the computer on which the instance of SQL Server is running. The time zone is not included, and it is returned as a datetime2 value. The fractional second precision specification has a range from 1 to 7 digits. The default precision is 7 digits.

SYSUTCDATETIME() does the same thing that GETUTCDATE() does, except that it returns a higher fractional precision. As mentioned,  SYSUTCDATETIME() returns a datetime2 value, whereas the GETUTCDATE() function returns a datetime value.

Continue reading

GETUTCDATE() Examples in SQL Server (T-SQL)

When using SQL Server, you can use the T-SQL GETUTCDATE() function to return the current UTC time (Coordinated Universal Time). UTC time is the primary time standard by which the world regulates clocks and time.

The return value of the GETUTCDATE() function is derived from the computer on which the instance of SQL Server is running. The time zone is not included, and it is returned as a datetime value.

Continue reading

CURRENT_TIMESTAMP Examples in SQL Server (T-SQL)

The CURRENT_TIMESTAMP function returns the current date and time as a datetime value. This value is derived from the operating system of the computer that the instance of SQL Server is running on.

This function is the ANSI SQL equivalent to the T-SQL GETDATE() function, so you can use whichever one you prefer. Note that both functions have a lower date range and a lower default fractional precision than the T-SQL SYSDATETIME() function (which returns a datetime2(7) value).

This article provides examples of the CURRENT_TIMESTAMP function, including how you can use it with other functions to return the value you’re interested in.

Continue reading

GETDATE() Examples in SQL Server (T-SQL)

The GETDATE() function returns the current date and time as a datetime value. This value is derived from the operating system of the computer that the instance of SQL Server is running on.

This article provides examples of the GETDATE() function, including how you can use it with other functions to return the value you’re interested in.

Continue reading

SYSDATETIME() Examples in SQL Server (T-SQL)

The SYSDATETIME() function returns the current date and time as a datetime2(7) value. This value is derived from the operating system of the computer that the instance of SQL Server is running on.

This article provides examples of the SYSDATETIME() function, including how you can use it with other functions to return the value you’re interested in.

Continue reading

DATETIME2FROMPARTS() Examples in SQL Server (T-SQL)

In SQL Server, the DATETIME2FROMPARTS() function works similar to the DATETIMEFROMPARTS() function, except that it accepts 8 arguments and returns a datetime2 value. The DATETIMEFROMPARTS() function on the other hand, accepts just 7 arguments and it returns a datetime value.

Basically, you provide all the date/time parts and this function will return a datetime2 value based on the parts you provide.

Continue reading