Skip to content

TIME

The TIME data type stores 8-byte time of day values that do not include the date or time zone. If input values contain dates and time zones, they are ignored.

You cannot define a TIME column with a specific precision for fractional seconds. All TIME values support up to six fractional seconds; if additional fractional digits exist in input values, the time is rounded up or down, as appropriate.

Values inserted with INSERT statements must fall between 00:00:00 and 24:00:00. Values inserted with ybload bulk loads must fall between 00:00:00 and 23:59:59. Time values may also include the am or pm designation.

The following table shows examples of values that can be inserted into a TIME column.

Inserted ValueStored ValueNotes
01:01:0101:01:01
23:59:59.12323:59:59.123Three digits representing fractional seconds are inserted.
00:00:00.99999900:00:00.999999Six digits representing fractional seconds are inserted.
01:00:00.99999955501:00:01.000000The fractional seconds (9 digits) are rounded up.
2017-05-25 00:00:00.9999999 GMT00:00:01The date is ignored. The time zone is ignored. The fractional seconds (7 digits) are rounded up.
24:00:00.123Value out of rangeReturns an error.
02:02:45.6789pm14:02:45.6789am and pm can be specified in uppercase or lowercase.
02:02:45.6789 am02:02:45.6789The space before am or pm is optional.

Note: You cannot add two TIME values. However, you can subtract a TIME value from another TIME value, which produces an INTERVAL value. For example:

premdb=# select time '12:00:00' - time '3:30:30' as timeleft 
from sys.const;
 timeleft 
----------
 08:29:30
(1 row)

Parent topic:SQL Data Types