The TSQL DATEPART Function
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 …