Instruction
PostgreSQL uses the time data type to store time data. Its range is '00:00:00' to '24:00:00' and for time with time zone from '00:00:00+1459' to '24:00:00-1459'. Time in PostgreSQL can contain also the number of fractional seconds. As you saw, the format for this data type is:
HH:MM:SS.n
Breaking this down, we see that:
HHstands for hours.MMstands for minutes. Each minute is represented by two digits from00to59.SSstands for seconds. Each second is represented by two digits from00to59..nstands for the number of fractional seconds. This optional value can range from 0 to 6 digits. By default, its value is0.
So we have the time data type. Notice that time uses a 24-hour clock, so write 14:25 for 2:25 PM.
The precision of time depends on the database designer; in our database, we use the default zero precision.
Specifying a value in a column of time type requires you to put the value in single quotes:
SELECT code, departure_time FROM route WHERE arrival_time = '20:15:00';
Exercise
Show the code for the PerfectAir route arriving at 9:30 AM.
Stuck? Here's a hint!
Don't use "AM" – databases use 24 hours clock 😉



