0
0
MySQLquery~5 mins

DATE_FORMAT function in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the DATE_FORMAT function do in MySQL?
It formats a date or datetime value according to a specified format string, returning the result as text.
Click to reveal answer
beginner
How do you format a date to show only the year using DATE_FORMAT?
Use DATE_FORMAT(date, '%Y') to get the 4-digit year from a date.
Click to reveal answer
intermediate
What format specifier would you use in DATE_FORMAT to display the month as a full name?
Use %M to display the full month name, like 'January' or 'February'.
Click to reveal answer
intermediate
Write a DATE_FORMAT example to display a date as 'Day-Month-Year', like '05-April-2024'.
Use DATE_FORMAT(date, '%d-%M-%Y') to format the date as '05-April-2024'.
Click to reveal answer
intermediate
Can DATE_FORMAT be used to format time parts like hours and minutes?
Yes, you can use specifiers like %H for hours and %i for minutes to format time.
Click to reveal answer
Which format specifier in DATE_FORMAT returns the full month name?
A%M
B%m
C%b
D%d
What will DATE_FORMAT('2024-06-15', '%Y-%m-%d') return?
A15-06-2024
B06/15/2024
CJune 15, 2024
D2024-06-15
Which DATE_FORMAT specifier shows the hour in 24-hour format?
A%h
B%I
C%H
D%p
How would you format a date to show 'Friday, 05 April 2024' using DATE_FORMAT?
A%w, %d %m %Y
B%W, %d %M %Y
C%D, %d %M %Y
D%A, %d %M %Y
What type of value does DATE_FORMAT return?
AString
BDatetime
CInteger
DDate
Explain how the DATE_FORMAT function works and give an example of formatting a date to 'YYYY/MM/DD'.
Think about how you tell MySQL to show a date in a specific way.
You got /3 concepts.
    List at least three different format specifiers used in DATE_FORMAT and what they represent.
    Remember specifiers are like codes that tell MySQL what part of the date/time to show.
    You got /4 concepts.