Aan de slagGa gratis aan de slag

Cleaning invalid dates

The date_first_observed column in the parking_violation dataset represents the date when the parking violation was first observed by the individual recording the violation. Unfortunately, not all date_first_observed values were recorded properly. Some records contain a '0' value for this column. A '0' value cannot be interpreted as a DATE automatically as its meaning in this context is ambiguous. The column values require cleaning to enable conversion to a proper DATE column.

In this exercise, you will convert the date_first_observed value of records with a '0' date_first_observed value into NULL values using the NULLIF() function, so that the field can be represented as a proper date.

Deze oefening maakt deel uit van de cursus

Cleaning Data in PostgreSQL Databases

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

SELECT
  -- Replace '0' with NULL
  ___(___, ___) AS date_first_observed
FROM
  parking_violation;
Code bewerken en uitvoeren