Using the TSQL GetDate Function

Download PDF

Here is a quick video tutorial on how to use the T-SQL GetDate function on SQL Server 2012, SQL Server 2014 or newer. This was originally part of my free SQL query training for the 70-461 certification exam.

Here is the sample code that goes with the video.

-- GETDATE()
SELECT GETDATE();

-- GETDATE just as a TIME
SELECT CONVERT (time, GETDATE());

-- comparing GETDATE() to others
SELECT CONVERT (time, GETDATE()) AS [getDate],
       CONVERT (time, SYSDATETIME()) AS [sysDateTime],
       CONVERT (time, SYSUTCDATETIME()) AS [sysUtcDateTime],
       CONVERT (time, CURRENT_TIMESTAMP) AS [current_timestamp],
       CONVERT (time, GETUTCDATE()) AS [getUtcDate];

See Also

Posted in 70-461 Training, TSQL Tagged with: , , , ,

Leave a Reply

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

*

Time limit is exhausted. Please reload CAPTCHA.