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 - SQL Server Tutorial
From the course: Querying Microsoft SQL Server 2022
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
Use functions in T-SQL3m 10s
-
(Locked)
String functions3m 44s
-
(Locked)
Text concatenation3m 40s
-
(Locked)
Round with mathematical functions3m 13s
-
(Locked)
Find the GREATEST or LEAST value5m 5s
-
(Locked)
Work with date functions5m 56s
-
(Locked)
FORMAT date and times3m 36s
-
(Locked)
Group dates into buckets6m 10s
-
(Locked)
Return random records with NEWID2m 22s
-
(Locked)
Create a series of values5m 13s
-
(Locked)
The IIF logical function3m 39s
-
(Locked)
Write a CASE statement4m 34s
-
(Locked)
Challenge: Use functions in a SQL query49s
-
(Locked)
Solution: Use functions in a SQL query13m 55s
-
-
-
-
-
-