0
0
MySQLquery~30 mins

DATE_FORMAT function in MySQL - Mini Project: Build & Apply

Choose your learning style9 modes available
Formatting Dates with DATE_FORMAT in MySQL
📖 Scenario: You work in a small company database team. Your manager wants to display customer signup dates in a friendlier format on the website.
🎯 Goal: Learn how to use the MySQL DATE_FORMAT function to change the appearance of date values in query results.
📋 What You'll Learn
Create a table called customers with columns id, name, and signup_date
Insert three customers with specific signup dates
Write a query selecting customer names and their signup dates formatted as 'Month day, Year' (e.g., 'January 5, 2023')
Use the DATE_FORMAT function with the correct format string
💡 Why This Matters
🌍 Real World
Formatting dates nicely is important for user-friendly reports, websites, and applications that show dates.
💼 Career
Database developers and analysts often need to format dates for reports and user interfaces using functions like DATE_FORMAT.
Progress0 / 4 steps
1
Create the customers table
Write a SQL statement to create a table called customers with these columns: id as an integer primary key, name as a VARCHAR(50), and signup_date as a DATE.
MySQL
Need a hint?

Use CREATE TABLE with the exact column names and types.

2
Insert three customers with signup dates
Write SQL INSERT statements to add these customers to the customers table: (1, 'Alice', '2023-01-05'), (2, 'Bob', '2023-02-15'), and (3, 'Charlie', '2023-03-20').
MySQL
Need a hint?

Use a single INSERT INTO statement with multiple rows.

3
Write a query to select names and formatted signup dates
Write a SQL SELECT statement to get the name and the signup_date formatted as 'Month day, Year' using DATE_FORMAT(signup_date, '%M %e, %Y'). Name the formatted column formatted_date.
MySQL
Need a hint?

Use DATE_FORMAT with the format string '%M %e, %Y' to get 'Month day, Year'.

4
Complete the query with ordering by signup date
Add an ORDER BY signup_date clause to the previous SELECT statement to show customers sorted by their signup date from earliest to latest.
MySQL
Need a hint?

Use ORDER BY signup_date at the end of the query.