Friday , March 29 2024

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.

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories