From the course: Querying Microsoft SQL Server 2022

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Work with date functions

Work with date functions

- [Instructor] When working with dates and times, there's a number of functions that you should be familiar with. Let's take a look at them by pulling the business entity ID and the hire date columns for all of the employees found in the humanresources.employeetable. We'll execute this simple query and we'll see the data that we'll work with. Now, first, there's a number of functions that will extract and separate portions of the date. Let's take a look at the first one called year. The year function will just return the year from a given date. We'll apply this to the hire date data. I'll name this new column as hire year. The next function is called month and it does the same thing, it just extracts the month from a date. And finally, there's a day function that does essentially the same thing. It returns the day from a date. I'll execute this updated query to see the three new rows and we can see all the portions of…

Contents