From the course: Querying Microsoft SQL Server 2019

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Work with date functions

Work with date functions - SQL Server Tutorial

From the course: Querying Microsoft SQL Server 2019

Start my 1-month free trial

Work with date functions

- [Instructor] When working with dates and times, there are a number of functions that you should be familiar with. Let's take a look by creating a new query that pulls in the business entity ID and hire dates of the employees found in the HumanResources.Employee table. This'll give us some dates that we can play around with. You can see those right here. First, there's a number of functions that'll extract and separate portions of the date. Let's go ahead and start adding these on line number three. The YEAR function will return just the year. I'll apply that to the HireDate data. The MONTH function will return just the month from the original date. And the DAY function will do the same thing. It'll return just the day portion of the date. These functions are great for breaking down your data so they can be used for grouping. Here I have just the years from each of the dates. Here's the original dates just there. We…

Contents