SQL Server DATETIME, DATE and TIME data types | Manipulating Dates, times and Strings | SQL basics

Описание к видео SQL Server DATETIME, DATE and TIME data types | Manipulating Dates, times and Strings | SQL basics

SQL Server DATETIME, DATE and TIME data types are essential to know before attempting pretty much any query involving time periods in data. Knowing how to convert date and time types to and from string values can prove problematic if you arent familiar with how SQL server defines and parses dates.

In this video I'll show you each DATE data type and describe its basic form, how to convert dates to and from strings, and the issues you might have trying to query against date values due to the locale settings on your SQL server.

I'll also go through how to manipulate dates and times by separating out date parts using the DATEPART and DATENAME functions, retrieving the current date using either GETDATE() or CURRENT_TIMESTAMP functions, adding, subtracting and finding the difference between dates using the DATEADD and DATEDIFF functions, and finally how to use what you've learned to create functions that show the first and last dates of the week, month or quarter.



Download the SQL code from Github : https://bit.ly/3GMwgQ7

See my introductory Udemy course on the full features of the SELECT clause : https://bit.ly/3EslGwo



Useful links relating to this video :

https://www.mssqltips.com/sqlserverti...
An excellent overview of the main SQL Server date and time functions all in one place.

https://jasonstrate.com/2010/03/10/gr...
A great article on rounding dates to get different set periods such as the first date in a month or a quarter etc.

https://docs.microsoft.com/en-us/sql/...
The link to the Microsoft documentation on the CAST and CONVERT functions, showing all the available styles.

https://docs.microsoft.com/en-us/sql/...
Microsoft documentation detailing the limitations of each date data type.

https://docs.microsoft.com/en-us/dotn...
Documentation for the FORMAT function, showing the different types of date and time formatting codes.

https://www.red-gate.com/simple-talk/...
A further look into how SQL server stores dates and times, and a few important things to remember when working with dates and times



Video Chapters

00:00 Intro
00:29 Date and Time Datatypes
04:13 How Dates are stored in the database
06:05 Converting a date to a string
09:17 Converting a string to a date
10:59 Separating dates from times
12:22 Getting the current date and time
13:11 Getting parts of dates and times with DATEPART and DATENAME
14:10 Finding the difference between two dates with DATEDIFF
14:59 Adding and subtracting periods to a date with DATEADD
15:18 Get first / last day of the week / month / quarter
19:01 Outro

Комментарии

Информация по комментариям в разработке