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

 

More from Stedman Solutions:

SteveStedman5
Steve and the team at Stedman Solutions are here for all your SQL Server needs.
Contact us today for your free 30 minute consultation..
We are ready to help!

Leave a Reply

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

*