PostgreSQL uses the
time data type to store time data. Its range is
'24:00:00' and for
time with time zone from
'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:
Breaking this down, we see that:
HH stands for hours.
MM stands for minutes. Each minute is represented by two digits from
SS stands for seconds. Each second is represented by two digits from
.n stands for the number of fractional seconds. This optional value can range from 0 to 6 digits. By default, its value is
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:
WHERE arrival_time = '20:15:00';