CommencerCommencer gratuitement

Extracting time units with SUBSTRING()

In a previous exercise, you separated the interval between the violation_time and to_hours_in_effect columns into their constituent hour and minute time units. Some pre-cleaning of these values was done behind the scenes to make the values more amenable for conversion because of inconsistencies in the recording of these values. The functions explored in this lesson provide an approach to extract values from strings.

In this exercise, you will use SUBSTRING() to extract the hour and minute units from time strings. This is an alternative approach to extracting time units removing the need to convert the string to a TIMESTAMP value to extract the time unit as was done previously.

Cet exercice fait partie du cours

Cleaning Data in PostgreSQL Databases

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

SELECT
  -- Define hour column
  ___(___ ___ ___ ___ ___) AS ___
FROM
  parking_violation;
Modifier et exécuter le code