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
Timezone conversion
Format date and time
Current date and time data
45. The CURRENT_DATE and CURRENT_TIME functions
Summary

Instruction

Good job! You can individually pull the local time or the local date with the CURRENT_DATE and CURRENT_TIME functions. The query below gets the current date and time:

SELECT CURRENT_DATE, CURRENT_TIME;

It returns the current date and time (with the time zone and full precision of fractional seconds), respectively.

Exercise

Do you know how long until our flights arrive in hours? Check the difference between the current and arrival time of the routes. Select the route code and the difference of time between the arrival and now. Name this column difference_hours.

Stuck? Here's a hint!

Use this expression:

DATE_PART('hour', CURRENT_TIMESTAMP) - DATE_PART('hour', arrival_time) AS difference_hours