Converting and displaying dates
The parking_violation dataset with which we have been working has two date columns where dates are represented in different formats: issue_date and date_first_observed. This is the case because these columns were imported into the database table as TEXT types. Using the DATE formatting approaches covered in the video exercise, it is possible to convert the dates from TEXT values into proper DATE columns and then output the dates in a consistent format.
In this exercise, you will use DATE() to convert vehicle_expiration_date and issue_date into DATE types and TO_CHAR() to display each value in the YYYYMMDD format.
Este exercício faz parte do curso
Cleaning Data in PostgreSQL Databases
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
SELECT
summons_number,
-- Convert issue_date to a DATE
___(___) AS issue_date,
-- Convert date_first_observed to a DATE
___(___) AS date_first_observed
FROM
parking_violation;