0
0
MySQLquery~10 mins

DATE_FORMAT function in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to format the date as 'Year-Month-Day'.

MySQL
SELECT DATE_FORMAT(order_date, '[1]') AS formatted_date FROM orders;
Drag options to blanks, or click blank then click option'
A'%Y-%m-%d'
B'%d/%m/%Y'
C'%m-%d-%Y'
D'%H:%i:%s'
Attempts:
3 left
💡 Hint
Common Mistakes
Using slashes instead of dashes in the format string.
Using time format specifiers instead of date.
2fill in blank
medium

Complete the code to display the date as 'Month name Day, Year' (e.g., June 15, 2024).

MySQL
SELECT DATE_FORMAT(order_date, '[1]') AS formatted_date FROM orders;
Drag options to blanks, or click blank then click option'
A'%d-%m-%Y'
B'%M %e, %Y'
C'%m %d %Y'
D'%Y/%m/%d'
Attempts:
3 left
💡 Hint
Common Mistakes
Using %m instead of %M for month name.
Using %d which adds leading zero to day.
3fill in blank
hard

Fix the error in the code to correctly format the date as 'Day/Month/Year'.

MySQL
SELECT DATE_FORMAT(order_date, '[1]') AS formatted_date FROM orders;
Drag options to blanks, or click blank then click option'
A'%d/%m/%Y'
B'%d-%m-%Y'
C'%Y/%m/%d'
D'%m/%d/%Y'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping month and day positions.
Using dashes instead of slashes.
4fill in blank
hard

Fill both blanks to format the date as 'Hour:Minute AM/PM' (e.g., 03:45 PM).

MySQL
SELECT DATE_FORMAT(order_time, '[1]:[2] %p') AS formatted_time FROM orders;
Drag options to blanks, or click blank then click option'
A%h
B%i
C%H
D%m
Attempts:
3 left
💡 Hint
Common Mistakes
Using %H instead of %h for 12-hour format.
Using %m which is month, not minutes.
5fill in blank
hard

Fill all three blanks to format the date as 'Weekday, Month Day, Year' (e.g., Monday, June 15, 2024).

MySQL
SELECT DATE_FORMAT(order_date, '[1], [2] [3], %Y') AS formatted_date FROM orders;
Drag options to blanks, or click blank then click option'
A%W
B%M
C%e
D%d
Attempts:
3 left
💡 Hint
Common Mistakes
Using %d instead of %e for day.
Using abbreviated weekday instead of full name.