Using DATE_FORMAT and EXTRACT to Analyze Sales Dates
📖 Scenario: You work for a retail company that tracks sales data. Each sale has a date stored in the database. You want to learn how to format these dates and extract parts like the year and month to better understand sales trends.
🎯 Goal: Build SQL queries that use DATE_FORMAT to display dates in a friendly way and EXTRACT to get the year and month from sales dates.
📋 What You'll Learn
Create a table called
sales with columns sale_id (integer) and sale_date (date).Insert specific sales dates into the
sales table.Write a query using
DATE_FORMAT to show sales dates as 'Month Day, Year'.Write a query using
EXTRACT to get the year and month from each sale date.💡 Why This Matters
🌍 Real World
Formatting and extracting parts of dates is common in sales reports, analytics, and scheduling systems.
💼 Career
Database professionals often write queries to transform and analyze date data for business insights.
Progress0 / 4 steps