One thing that I end up having to look search on regularly is rounding of dates and times in Transact SQL, having looked this up too many times I finally realized that it is time for me to do my own blog post for it. First off, whats the difference between rounding and truncating in these examples. Rounding rounds to …

TSQL Rounding or Truncating Date Time to Nearest Day, Hour, Minute or Second Read more »

Here is a quick video training on how to use the T-SQL DATEPART function on SQL Server. This was originally part of my free SQL query training for the 70-461 certification exam. And here is the sample code to go with the video tutorial: See Also Additional Training on my YouTube Channel Free SQL Query Training 70-461 exam preparation

You can use the TSQL DATEPART function to extract individual parts of the date from a date or time item. For instance: Will return the following output:   The second parameter is the date/time element which can be any of these types: time, date, smalldatetime, datetime, datetime2, or datetimeoffset.   Lets take a look at the possible options for the first …

The TSQL DATEPART Function Read more »

Here is a quick rundown on the T-SQL DATEPART function for SQL Server. DATEPART is used to pull a single part of a date/time element out as shown below. The following query uses DATEPART to extract the year from the datetime input. The following query uses DATEPART to extract the quarter from the datetime input. The following query uses DATEPART …

T-SQL DATEPART Explained Read more »

One thing that I end up having to look search on regularly is rounding of dates and times in Transact SQL, having looked this up too many times I finally realized that it is time for me to do my own blog post for it. First off, whats the difference between rounding and truncating in these examples. Rounding rounds to …

TSQL Rounding or Truncating DateTime to Nearest Day, Hour, Minute or Second Read more »