SQL DATEDIFF Function Explained
Автор: Ryan & Matt Data Science
Загружено: 2023-05-29
Просмотров: 4810
🧠 Don’t miss out! Get FREE access to my Skool community — packed with resources, tools, and support to help you with Data, Machine Learning, and AI Automations! 📈 https://www.skool.com/data-and-ai-aut...
Today we are taking a look at the DateDiff() function within SQL. We go over examples of using it in the Select statement as well as the where clause.
🚀 Hire me for Data Work: https://ryanandmattdatascience.com/da...
👨💻 Mentorships: https://ryanandmattdatascience.com/me...
📧 Email: ryannolandata@gmail.com
🌐 Website & Blog: https://ryanandmattdatascience.com/
🖥️ Discord: / discord
📚 *Practice SQL & Python Interview Questions: https://stratascratch.com/?via=ryan
📖 *SQL and Python Courses: https://datacamp.pxf.io/XYD7Qg
🍿 WATCH NEXT
SQL Tutorials Playlist: • SQL Tutorials for Data Analysts
SQL Stored Procedures: • SQL Stored Procedures Made Easy: 3 Essenti...
SQL Rank, Dense Rank, Row Number: • SQL Rank, Dense Rank, and Row Number Tutor...
SQL Partition by: • SQL Partition By Tutorial With Examples!
In this tutorial, I break down the SQL DATEDIFF function and show you exactly how to use it in both SELECT statements and WHERE clauses for filtering data. The DATEDIFF function is essential for comparing two dates and calculating the time difference between them, whether you need years, months, weeks, days, or even nanoseconds.
I walk through multiple practical examples using a sample database table, demonstrating how to compare dates against the current date using GETDATE(), and how to filter records based on time differences. You'll see real SQL queries in action, including how to find all records from a specific year, calculate month differences, and identify future dates using negative values.
By the end of this video, you'll understand the DATEDIFF syntax completely—including the date type parameter, start date, and end date—and know how to apply it in real-world scenarios like building reports and filtering datasets. This is a function you'll encounter frequently in coding interviews, LeetCode problems, and everyday database work, so it's crucial to master.
Whether you're preparing for SQL interviews or building production reports, this tutorial gives you the foundation you need to work confidently with date calculations in SQL Server.
TIMESTAMPS
00:00 Introduction to Date Diff Function
00:26 Date Diff Syntax and Arguments
01:06 Get Date Function Explained
01:40 Setup: Random Dates Table
02:07 Year Difference Example
03:13 Using Date Diff in Where Clause
04:09 Month Difference Example
04:55 Day and Week Difference Examples
OTHER SOCIALS:
Ryan’s LinkedIn: / ryan-p-nolan
Matt’s LinkedIn: / matt-payne-ceo
Twitter/X: https://x.com/RyanMattDS
Who is Ryan
Ryan is a Data Scientist at a fintech company, where he focuses on fraud prevention in underwriting and risk. Before that, he worked as a Data Analyst at a tax software company. He holds a degree in Electrical Engineering from UCF.
Who is Matt
Matt is the founder of Width.ai, an AI and Machine Learning agency. Before starting his own company, he was a Machine Learning Engineer at Capital One.
*This is an affiliate program. We receive a small portion of the final sale at no extra cost to you.
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: