(1 row)
SET DateStyle = 'ISO';
--- Reject time without time zone having a time zone specified
+-- As of 7.4, allow time without time zone having a time zone specified
SELECT time without time zone '040506.789+08';
-ERROR: Bad time external representation '040506.789+08'
+ time
+---------------
+ 04:05:06.7890
+(1 row)
+
SELECT time without time zone '040506.789-08';
-ERROR: Bad time external representation '040506.789-08'
+ time
+---------------
+ 04:05:06.7890
+(1 row)
+
SELECT time without time zone 'T040506.789+08';
-ERROR: Bad time external representation 'T040506.789+08'
+ time
+---------------
+ 04:05:06.7890
+(1 row)
+
SELECT time without time zone 'T040506.789-08';
-ERROR: Bad time external representation 'T040506.789-08'
+ time
+---------------
+ 04:05:06.7890
+(1 row)
+
SELECT time with time zone '040506.789+08';
timetz
------------------
(1 row)
SELECT date '1991-02-03' + interval '2 years' AS "Add Two Years";
- Add Two Years
-------------------------------
- Wed Feb 03 00:00:00 1993 PST
+ Add Two Years
+--------------------------
+ Wed Feb 03 00:00:00 1993
(1 row)
SELECT date '2001-12-13' - interval '2 years' AS "Subtract Two Years";
- Subtract Two Years
-------------------------------
- Mon Dec 13 00:00:00 1999 PST
+ Subtract Two Years
+--------------------------
+ Mon Dec 13 00:00:00 1999
(1 row)
-- subtract time from date should not make sense; use interval instead
SELECT date '1991-02-03' - time '04:05:06' AS "Subtract Time";
- Subtract Time
-------------------------------
- Sat Feb 02 19:54:54 1991 PST
+ Subtract Time
+--------------------------
+ Sat Feb 02 19:54:54 1991
(1 row)
SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time UTC";
-ERROR: Unable to identify an operator '-' for types 'date' and 'time with time zone'
- You will have to retype this query using an explicit cast
+ERROR: operator does not exist: date - time with time zone
+HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
--
-- timestamp, interval arithmetic
--
Fri Dec 31 23:59:59 1999
(1 row)
+SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '106000000 days' AS "Feb 23, 285506";
+ Feb 23, 285506
+----------------------------
+ Fri Feb 23 00:00:00 285506
+(1 row)
+
+SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '107000000 days' AS "Jan 20, 288244";
+ Jan 20, 288244
+----------------------------
+ Sat Jan 20 00:00:00 288244
+(1 row)
+
+SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '109203489 days' AS "Dec 31, 294276";
+ Dec 31, 294276
+----------------------------
+ Sun Dec 31 00:00:00 294276
+(1 row)
+
+SELECT timestamp without time zone '12/31/294276' - timestamp without time zone '12/23/1999' AS "106751991 Days";
+ 106751991 Days
+------------------
+ @ 106751991 days
+(1 row)
+
-- Shorthand values
-- Not directly usable for regression testing since these are not constants.
-- So, just try to test parser and hope for the best - thomas 97/04/26
Sat Jan 01 10:00:00 1994
(1 row)
-SELECT date '1994-01-01' + time '11:00-5' AS "Jan_01_1994_8am";
-ERROR: Bad time external representation '11:00-5'
-SELECT "timestamp"(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_11am";
- Jan_01_1994_11am
---------------------------
- Sat Jan 01 11:00:00 1994
+SELECT date '1994-01-01' + timetz '11:00-5' AS "Jan_01_1994_8am";
+ Jan_01_1994_8am
+------------------------------
+ Sat Jan 01 08:00:00 1994 PST
+(1 row)
+
+SELECT timestamptz(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_8am";
+ Jan_01_1994_8am
+------------------------------
+ Sat Jan 01 08:00:00 1994 PST
(1 row)
SELECT '' AS "64", d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL;
| Sat Feb 14 17:32:01 1998
| Sun Feb 15 17:32:01 1998
| Mon Feb 16 17:32:01 1998
- | Thu Feb 16 17:32 0096 BC
+ | Thu Feb 16 17:32:01 0096 BC
| Sun Feb 16 17:32:01 0098
| Fri Feb 16 17:32:01 0598
| Wed Feb 16 17:32:01 1098
| Wed Feb 14 17:32:01 1996
| Thu Feb 15 17:32:01 1996
| Fri Feb 16 17:32:01 1996
- | Mon Feb 16 17:32 0098 BC
+ | Mon Feb 16 17:32:01 0098 BC
| Thu Feb 16 17:32:01 0096
| Tue Feb 16 17:32:01 0596
| Sun Feb 16 17:32:01 1096
| Sat Feb 14 17:32:01 1998 PST
| Sun Feb 15 17:32:01 1998 PST
| Mon Feb 16 17:32:01 1998 PST
- | Thu Feb 16 17:32 0096 BC
+ | Thu Feb 16 17:32:01 0096 BC
| Sun Feb 16 17:32:01 0098
| Fri Feb 16 17:32:01 0598
| Wed Feb 16 17:32:01 1098
| Wed Feb 14 17:32:01 1996 PST
| Thu Feb 15 17:32:01 1996 PST
| Fri Feb 16 17:32:01 1996 PST
- | Mon Feb 16 17:32 0098 BC
+ | Mon Feb 16 17:32:01 0098 BC
| Thu Feb 16 17:32:01 0096
| Tue Feb 16 17:32:01 0596
| Sun Feb 16 17:32:01 1096
(1 row)
SELECT CAST(time with time zone '01:02-08' AS interval) AS "+00:01";
-ERROR: Cannot cast type 'time with time zone' to 'interval'
+ERROR: Cannot cast type time with time zone to interval
SELECT CAST(interval '02:03' AS time with time zone) AS "02:03:00-08";
-ERROR: Cannot cast type 'interval' to 'time with time zone'
+ERROR: Cannot cast type interval to time with time zone
SELECT time with time zone '01:30-08' - interval '02:01' AS "23:29:00-08";
23:29:00-08
-------------
f
(1 row)
-CREATE TABLE TEMP_TIMESTAMP (f1 timestamp);
+CREATE TABLE TEMP_TIMESTAMP (f1 timestamp with time zone);
-- get some candidate input values
INSERT INTO TEMP_TIMESTAMP (f1)
SELECT d1 FROM TIMESTAMP_TBL
| Sat Sep 22 18:19:20 2001 PDT | @ 14 secs ago | Sat Sep 22 18:19:34 2001 PDT
(160 rows)
-SELECT '' AS "16", d.f1 AS "timestamp", timestamp '1980-01-06 00:00 GMT' AS gpstime_zero,
- d.f1 - timestamp '1980-01-06 00:00 GMT' AS difference
+SELECT '' AS "16", d.f1 AS "timestamp",
+ timestamp with time zone '1980-01-06 00:00 GMT' AS gpstime_zero,
+ d.f1 - timestamp with time zone '1980-01-06 00:00 GMT' AS difference
FROM TEMP_TIMESTAMP d
ORDER BY difference;
16 | timestamp | gpstime_zero | difference
SELECT '' AS three, f1 as abstime, cast(f1 as timestamp) AS "timestamp"
FROM ABSTIME_TBL WHERE NOT isfinite(f1);
-ERROR: Unable to convert abstime 'invalid' to timestamptz
+ERROR: Unable to convert abstime 'invalid' to timestamp
SELECT '' AS ten, f1 AS interval, reltime(f1) AS reltime
FROM INTERVAL_TBL;
ten | interval | reltime
--
SET DateStyle TO 'US,Postgres';
SHOW DateStyle;
-INFO: DateStyle is Postgres with US (NonEuropean) conventions
+ DateStyle
+--------------
+ Postgres, US
+(1 row)
+
SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
64 | us_postgres
----+-----------------------------
| Fri Feb 14 17:32:01 1997
| Sat Feb 15 17:32:01 1997
| Sun Feb 16 17:32:01 1997
- | Tue Feb 16 17:32 0097 BC
+ | Tue Feb 16 17:32:01 0097 BC
| Sat Feb 16 17:32:01 0097
| Thu Feb 16 17:32:01 0597
| Tue Feb 16 17:32:01 1097
| 1997-02-14 17:32:01
| 1997-02-15 17:32:01
| 1997-02-16 17:32:01
- | 0097-02-16 17:32 BC
+ | 0097-02-16 17:32:01 BC
| 0097-02-16 17:32:01
| 0597-02-16 17:32:01
| 1097-02-16 17:32:01
SET DateStyle TO 'US,SQL';
SHOW DateStyle;
-INFO: DateStyle is SQL with US (NonEuropean) conventions
+ DateStyle
+-----------
+ SQL, US
+(1 row)
+
SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
64 | us_sql
----+------------------------
| 02/14/1997 17:32:01
| 02/15/1997 17:32:01
| 02/16/1997 17:32:01
- | 02/16/0097 17:32 BC
+ | 02/16/0097 17:32:01 BC
| 02/16/0097 17:32:01
| 02/16/0597 17:32:01
| 02/16/1097 17:32:01
SET DateStyle TO 'European,Postgres';
SHOW DateStyle;
-INFO: DateStyle is Postgres with European conventions
+ DateStyle
+--------------------
+ Postgres, European
+(1 row)
+
INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957');
SELECT count(*) as one FROM TIMESTAMP_TBL WHERE d1 = 'Jun 13 1957';
one
| Fri 14 Feb 17:32:01 1997
| Sat 15 Feb 17:32:01 1997
| Sun 16 Feb 17:32:01 1997
- | Tue 16 Feb 17:32 0097 BC
+ | Tue 16 Feb 17:32:01 0097 BC
| Sat 16 Feb 17:32:01 0097
| Thu 16 Feb 17:32:01 0597
| Tue 16 Feb 17:32:01 1097
SET DateStyle TO 'European,ISO';
SHOW DateStyle;
-INFO: DateStyle is ISO with European conventions
+ DateStyle
+---------------
+ ISO, European
+(1 row)
+
SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
65 | european_iso
----+------------------------
| 1997-02-14 17:32:01
| 1997-02-15 17:32:01
| 1997-02-16 17:32:01
- | 0097-02-16 17:32 BC
+ | 0097-02-16 17:32:01 BC
| 0097-02-16 17:32:01
| 0597-02-16 17:32:01
| 1097-02-16 17:32:01
SET DateStyle TO 'European,SQL';
SHOW DateStyle;
-INFO: DateStyle is SQL with European conventions
+ DateStyle
+---------------
+ SQL, European
+(1 row)
+
SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
65 | european_sql
----+------------------------
| 14/02/1997 17:32:01
| 15/02/1997 17:32:01
| 16/02/1997 17:32:01
- | 16/02/0097 17:32 BC
+ | 16/02/0097 17:32:01 BC
| 16/02/0097 17:32:01
| 16/02/0597 17:32:01
| 16/02/1097 17:32:01