SQL SERVER – 2008 – Get Current System Date Time

How to get current system date time in SQL Server?

First thing which comes to many users is using following script.

SELECT GETDATE() AS CurrentDateTime

Above method is not the only method to retrieve the current system date time for SQL Server. SQL Server 2008 has many different function which provides current system date time in different format and little difference in details.

SELECT 'SYSDATETIME' AS FunctionName, SYSDATETIME() AS DateTimeFormat
UNION ALL
SELECT 'SYSDATETIMEOFFSET', SYSDATETIMEOFFSET()
UNION ALL
SELECT 'SYSUTCDATETIME', SYSUTCDATETIME()
UNION ALL
SELECT 'CURRENT_TIMESTAMP', CURRENT_TIMESTAMP
UNION ALL
SELECT 'GETDATE', GETDATE()
UNION ALL
SELECT 'GETUTCDATE', GETUTCDATE()

In SQL Server 2008, use any of the above function depending on your need.

SQL SERVER - 2008 - Get Current System Date Time datetime2008

Quick Video on the same subject

[youtube=http://www.youtube.com/watch?v=BL5GO-jH3HA]

Reference : Pinal Dave (https://darkslategrey-bat-805937.hostingersite.com)

SQL DateTime, SQL Function, SQL Scripts, SQL Server
Previous Post
SQL SERVER – 2008 – Find Current System Date Time and Time Offset
Next Post
SQL SERVER – Effect of Order of Join In Query

Related Posts

Leave a Reply