๐Ÿ“Š We use cookies & analytics to improve your experience. Learn more
Latest

Data Analytics with SQL & Excel Module 4 ยท Lesson 10 of 15

0% Exit to course

Module 4 ยท Dates, windows and time Lesson 10 of 15

Dates and time in SQL

Learning objective

Dates are the most common filter in analytics and the one most often broken. Store them as real date columns, filter with ranges, and never compare a date to a string that only looks like one.

Worked example

WHERE created_at >= '2026-01-01' AND created_at < '2026-02-01' covers a whole month and still lets the database use an index on the column.

Your practice task

Count postings per month for the last six months, then count only the last seven days, and compare the two queries.

Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.

Key takeaway

Dates are the most common filter in analytics and the one most often broken. Store them as real date columns, filter with ranges, and never compare a date to a string that only looks like one.

Create free account or sign in

Almost there

15 lessons left of 15

Finish every lesson to unlock the certificate. Each one ends in a practice task โ€” do them and the final project brief writes itself.

Next recommended course Interview DSA Crash Course