T-SQL 101: 72 Extracting date and time components in SQL Server T-SQL using DATEPART
In previous posts, I mentioned that you can easily extract the year, month, and day from dates and times, but you might want other components. That’s what the DATEPART() function does.
You can see the output from the query above here:
To use this function , we put the interval that we’re after and then the value we want to find it out from. So if you look at this one, I said I wanted the day from 28th of February 2019. The day is 28.
2020-06-01