Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Dealing with dates
Working with time
Date and time data types in PostgreSQL
Extracting dates and times
24. DATE_PART() – example
Timezone conversion
Format date and time
Current date and time data
Summary

Instruction

Great! How can we use this function? For instance, we can use it to change the way dates are shown. Take a look:

SELECT
  DATE_PART('day', launched_timestamp)
    || '-'
    || DATE_PART('month', launched_timestamp)
    || '-'
    || DATE_PART('year', launched_timestamp)
    AS launched_date
FROM aircraft;

As a result, we get dates like '10-03-2012' instead of '2012-03-10'. However PostgreSQL implements various functions to work with time and date to format them. We will meet these functions in the next section of the course.

Exercise

For each route, show its code and the departure time in the following format: hh.mm, where hh is the hour and mm minutes. Name this new column departure_hour_minute.

Stuck? Here's a hint!

Use the concatenation sign || twice and don't forget about the dot between the hour and minute.