Get startedGet started for free

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.

This exercise is part of the course

Cleaning Data in PostgreSQL Databases

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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;
Edit and Run Code