Site icon Database Tutorials

GETDATE, GETUTCDATE, SYSDATETIME and SYSUTCDATETIME Functions in SQL Server(TSQL)

 

I will explain GETDATE, GETUTCDATE, SYSDATETIME and SYSUTCDATETIME functions in this article.

GETDATE Function in SQL Server(TSQL):

We can obtain current database timestamp as a datatime value using GETDATE function.

GETUTCDATE Function in SQL Server(TSQL):

We can obtain current database timestamp as a datatime value without database timezone offset using GETUTCDATE function.

For example, the timezone of SQL Server that I run the following script is UTC+3.

As you can see below, the GETUTCDATE function worked based “UTC” instead of “UTC+3”.

SYSDATETIME Function in SQL Server(TSQL):

We can obtain current date and time information as datetime2(7) value from the server on which SQL Server is running.

SYSUTCDATETIME Function in SQL Server(TSQL):

We can obtain current date and time information as datetime2(7) according to UTC from the server on which SQL Server is running.

Exit mobile version