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

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

In SQL Server, the DATETIMEFROMPARTS() function works just like the DATEFROMPARTS() function, except that it also returns the time portion of the date.

The DATETIMEFROMPARTS() function accepts seven arguments, each representing a different part of the date/time. The function then returns a datetime value from the given parts.

Continue reading