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 - SQL Server Tutorial
From the course: Querying Microsoft SQL Server 2019
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
-
-
-
-
-
-
-
(Locked)
Use functions in T-SQL2m 47s
-
(Locked)
String functions3m 24s
-
(Locked)
Text concatenation3m 33s
-
(Locked)
Round with mathematical functions2m 46s
-
(Locked)
Work with date functions4m 53s
-
(Locked)
FORMAT date and times2m 59s
-
(Locked)
Return random records with NEWID2m 2s
-
(Locked)
The IIF logical function3m 9s
-
(Locked)
-
-
-
-
-