0
0
PostgreSQLquery~10 mins

TO_CHAR for date formatting in PostgreSQL - 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 current date as 'YYYY-MM-DD'.

PostgreSQL
SELECT TO_CHAR(CURRENT_DATE, [1]);
Drag options to blanks, or click blank then click option'
A'DD/MM/YYYY'
B'YYYY-MM-DD'
C'MM-DD-YYYY'
D'YY-MM-DD'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong order of year, month, and day.
Forgetting to put the format string in quotes.
2fill in blank
medium

Complete the code to format the current timestamp as 'HH24:MI:SS'.

PostgreSQL
SELECT TO_CHAR(CURRENT_TIMESTAMP, [1]);
Drag options to blanks, or click blank then click option'
A'HH12:MI:SS AM'
B'HH:MM:SS'
C'HH24:MI:SS'
D'HH24:MM:SS'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'MM' instead of 'MI' for minutes.
Using 12-hour format when 24-hour is needed.
3fill in blank
hard

Fix the error in the code to format the date as 'Month DD, YYYY'.

PostgreSQL
SELECT TO_CHAR(CURRENT_DATE, [1]);
Drag options to blanks, or click blank then click option'
A'Month DD, YYYY'
B'month DD, YYYY'
C'MONTH DD, YYYY'
D'Mon DD, YYYY'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'month' which returns all lowercase month name.
Using 'Mon' which returns abbreviated month name.
4fill in blank
hard

Fill both blanks to format the timestamp as 'YYYY-MM-DD HH24:MI:SS'.

PostgreSQL
SELECT TO_CHAR(NOW(), [1] || ' ' || [2]);
Drag options to blanks, or click blank then click option'
A'YYYY-MM-DD'
B'HH24:MI:SS'
C'MM-DD-YYYY'
D'HH12:MI:SS AM'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 12-hour format instead of 24-hour.
Mixing up the order of date and time formats.
5fill in blank
hard

Fill all three blanks to format the date as 'Day, DD Month'.

PostgreSQL
SELECT TO_CHAR(CURRENT_DATE, [1] || ', ' || [2] || ' ' || [3]);
Drag options to blanks, or click blank then click option'
A'Day'
B'DD'
C'Month'
D'YYYY'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Mon' instead of 'Month' for full month name.
Forgetting the comma after the day name.