4 CREATE TABLE TIME_TBL (f1 time(2));
5 INSERT INTO TIME_TBL VALUES ('00:00');
6 INSERT INTO TIME_TBL VALUES ('01:00');
7 -- as of 7.4, timezone spec should be accepted and ignored
8 INSERT INTO TIME_TBL VALUES ('02:03 PST');
9 INSERT INTO TIME_TBL VALUES ('11:59 EDT');
10 INSERT INTO TIME_TBL VALUES ('12:00');
11 INSERT INTO TIME_TBL VALUES ('12:01');
12 INSERT INTO TIME_TBL VALUES ('23:59');
13 INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM');
14 INSERT INTO TIME_TBL VALUES ('2003-03-07 15:36:39 America/New_York');
15 INSERT INTO TIME_TBL VALUES ('2003-07-07 15:36:39 America/New_York');
16 -- this should fail (the timezone offset is not known)
17 INSERT INTO TIME_TBL VALUES ('15:36:39 America/New_York');
18 ERROR: invalid input syntax for type time: "15:36:39 America/New_York"
19 LINE 1: INSERT INTO TIME_TBL VALUES ('15:36:39 America/New_York');
21 SELECT f1 AS "Time" FROM TIME_TBL;
36 SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07';
44 SELECT f1 AS "Five" FROM TIME_TBL WHERE f1 > '05:06:07';
56 SELECT f1 AS "None" FROM TIME_TBL WHERE f1 < '00:00';
61 SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00';
77 SELECT '23:59:59.999999'::time;
83 SELECT '23:59:59.9999999'::time; -- rounds up
89 SELECT '23:59:60'::time; -- rounds up
95 SELECT '24:00:00'::time; -- allowed
101 SELECT '24:00:00.01'::time; -- not allowed
102 ERROR: date/time field value out of range: "24:00:00.01"
103 LINE 1: SELECT '24:00:00.01'::time;
105 SELECT '23:59:60.01'::time; -- not allowed
106 ERROR: date/time field value out of range: "23:59:60.01"
107 LINE 1: SELECT '23:59:60.01'::time;
109 SELECT '24:01:00'::time; -- not allowed
110 ERROR: date/time field value out of range: "24:01:00"
111 LINE 1: SELECT '24:01:00'::time;
113 SELECT '25:00:00'::time; -- not allowed
114 ERROR: date/time field value out of range: "25:00:00"
115 LINE 1: SELECT '25:00:00'::time;
120 -- We now make a distinction between time and intervals,
121 -- and adding two times together makes no sense at all.
122 -- Leave in one query to show that it is rejected,
123 -- and do the rest of the testing in horology.sql
124 -- where we do mixed-type arithmetic. - thomas 2000-12-02
125 SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
126 ERROR: operator is not unique: time without time zone + time without time zone
127 LINE 1: SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
129 HINT: Could not choose a best candidate operator. You might need to add explicit type casts.
133 SELECT EXTRACT(MICROSECOND FROM TIME '2020-05-26 13:30:25.575401');
139 SELECT EXTRACT(MILLISECOND FROM TIME '2020-05-26 13:30:25.575401');
145 SELECT EXTRACT(SECOND FROM TIME '2020-05-26 13:30:25.575401');
151 SELECT EXTRACT(MINUTE FROM TIME '2020-05-26 13:30:25.575401');
157 SELECT EXTRACT(HOUR FROM TIME '2020-05-26 13:30:25.575401');
163 SELECT EXTRACT(DAY FROM TIME '2020-05-26 13:30:25.575401'); -- error
164 ERROR: "time" units "day" not recognized
165 SELECT EXTRACT(FORTNIGHT FROM TIME '2020-05-26 13:30:25.575401'); -- error
166 ERROR: "time" units "fortnight" not recognized
167 SELECT EXTRACT(TIMEZONE FROM TIME '2020-05-26 13:30:25.575401'); -- error
168 ERROR: "time" units "timezone" not recognized
169 SELECT EXTRACT(EPOCH FROM TIME '2020-05-26 13:30:25.575401');
175 -- date_part implementation is mostly the same as extract, so only
176 -- test a few cases for additional coverage.
177 SELECT date_part('microsecond', TIME '2020-05-26 13:30:25.575401');
183 SELECT date_part('millisecond', TIME '2020-05-26 13:30:25.575401');
189 SELECT date_part('second', TIME '2020-05-26 13:30:25.575401');
195 SELECT date_part('epoch', TIME '2020-05-26 13:30:25.575401');