1997-05-11 17:42:09 +02:00
|
|
|
--
|
2000-01-05 07:07:58 +01:00
|
|
|
-- HOROLOGY
|
1997-05-11 17:42:09 +02:00
|
|
|
--
|
2003-07-29 02:03:19 +02:00
|
|
|
SET DateStyle = 'Postgres, MDY';
|
2001-09-28 10:00:11 +02:00
|
|
|
|
2002-01-12 05:38:38 +01:00
|
|
|
--
|
|
|
|
-- Test various input formats
|
|
|
|
--
|
|
|
|
SELECT timestamp with time zone '20011227 040506+08';
|
|
|
|
SELECT timestamp with time zone '20011227 040506-08';
|
|
|
|
SELECT timestamp with time zone '20011227 040506.789+08';
|
|
|
|
SELECT timestamp with time zone '20011227 040506.789-08';
|
|
|
|
SELECT timestamp with time zone '20011227T040506+08';
|
|
|
|
SELECT timestamp with time zone '20011227T040506-08';
|
|
|
|
SELECT timestamp with time zone '20011227T040506.789+08';
|
|
|
|
SELECT timestamp with time zone '20011227T040506.789-08';
|
|
|
|
SELECT timestamp with time zone '2001-12-27 04:05:06.789-08';
|
|
|
|
SELECT timestamp with time zone '2001.12.27 04:05:06.789-08';
|
|
|
|
SELECT timestamp with time zone '2001/12/27 04:05:06.789-08';
|
|
|
|
SELECT timestamp with time zone '12/27/2001 04:05:06.789-08';
|
2003-07-29 02:03:19 +02:00
|
|
|
-- should fail in mdy mode:
|
2002-01-12 05:38:38 +01:00
|
|
|
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
2003-07-29 02:03:19 +02:00
|
|
|
set datestyle to dmy;
|
|
|
|
SELECT timestamp with time zone '27/12/2001 04:05:06.789-08';
|
|
|
|
reset datestyle;
|
2002-01-12 05:38:38 +01:00
|
|
|
SELECT timestamp with time zone 'Y2001M12D27H04M05S06.789+08';
|
|
|
|
SELECT timestamp with time zone 'Y2001M12D27H04M05S06.789-08';
|
|
|
|
SELECT timestamp with time zone 'Y2001M12D27H04MM05S06.789+08';
|
|
|
|
SELECT timestamp with time zone 'Y2001M12D27H04MM05S06.789-08';
|
|
|
|
SELECT timestamp with time zone 'J2452271+08';
|
|
|
|
SELECT timestamp with time zone 'J2452271-08';
|
|
|
|
SELECT timestamp with time zone 'J2452271.5+08';
|
|
|
|
SELECT timestamp with time zone 'J2452271.5-08';
|
|
|
|
SELECT timestamp with time zone 'J2452271 04:05:06+08';
|
|
|
|
SELECT timestamp with time zone 'J2452271 04:05:06-08';
|
|
|
|
SELECT timestamp with time zone 'J2452271T040506+08';
|
|
|
|
SELECT timestamp with time zone 'J2452271T040506-08';
|
|
|
|
SELECT timestamp with time zone 'J2452271T040506.789+08';
|
|
|
|
SELECT timestamp with time zone 'J2452271T040506.789-08';
|
|
|
|
-- German/European-style dates with periods as delimiters
|
2003-07-29 02:03:19 +02:00
|
|
|
SELECT timestamp with time zone '12.27.2001 04:05:06.789+08';
|
|
|
|
SELECT timestamp with time zone '12.27.2001 04:05:06.789-08';
|
2002-01-12 05:38:38 +01:00
|
|
|
SET DateStyle = 'German';
|
|
|
|
SELECT timestamp with time zone '27.12.2001 04:05:06.789+08';
|
|
|
|
SELECT timestamp with time zone '27.12.2001 04:05:06.789-08';
|
|
|
|
SET DateStyle = 'ISO';
|
2003-01-31 02:08:08 +01:00
|
|
|
-- As of 7.4, allow time without time zone having a time zone specified
|
2002-01-12 05:38:38 +01:00
|
|
|
SELECT time without time zone '040506.789+08';
|
|
|
|
SELECT time without time zone '040506.789-08';
|
|
|
|
SELECT time without time zone 'T040506.789+08';
|
|
|
|
SELECT time without time zone 'T040506.789-08';
|
|
|
|
SELECT time with time zone '040506.789+08';
|
|
|
|
SELECT time with time zone '040506.789-08';
|
|
|
|
SELECT time with time zone 'T040506.789+08';
|
|
|
|
SELECT time with time zone 'T040506.789-08';
|
|
|
|
SELECT time with time zone 'T040506.789 +08';
|
|
|
|
SELECT time with time zone 'T040506.789 -08';
|
2003-07-29 02:03:19 +02:00
|
|
|
SET DateStyle = 'Postgres, MDY';
|
2010-09-23 05:48:07 +02:00
|
|
|
-- Check Julian dates BC
|
|
|
|
SELECT date 'J1520447' AS "Confucius' Birthday";
|
|
|
|
SELECT date 'J0' AS "Julian Epoch";
|
2002-01-12 05:38:38 +01:00
|
|
|
|
2000-09-12 07:42:20 +02:00
|
|
|
--
|
|
|
|
-- date, time arithmetic
|
|
|
|
--
|
|
|
|
|
|
|
|
SELECT date '1981-02-03' + time '04:05:06' AS "Date + Time";
|
|
|
|
SELECT date '1991-02-03' + time with time zone '04:05:06 PST' AS "Date + Time PST";
|
|
|
|
SELECT date '2001-02-03' + time with time zone '04:05:06 UTC' AS "Date + Time UTC";
|
|
|
|
SELECT date '1991-02-03' + interval '2 years' AS "Add Two Years";
|
|
|
|
SELECT date '2001-12-13' - interval '2 years' AS "Subtract Two Years";
|
2001-09-28 10:00:11 +02:00
|
|
|
-- subtract time from date should not make sense; use interval instead
|
2000-09-12 07:42:20 +02:00
|
|
|
SELECT date '1991-02-03' - time '04:05:06' AS "Subtract Time";
|
|
|
|
SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time UTC";
|
|
|
|
|
1997-05-11 17:42:09 +02:00
|
|
|
--
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
-- timestamp, interval arithmetic
|
1997-05-11 17:42:09 +02:00
|
|
|
--
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT timestamp without time zone '1996-03-01' - interval '1 second' AS "Feb 29";
|
|
|
|
SELECT timestamp without time zone '1999-03-01' - interval '1 second' AS "Feb 28";
|
|
|
|
SELECT timestamp without time zone '2000-03-01' - interval '1 second' AS "Feb 29";
|
|
|
|
SELECT timestamp without time zone '1999-12-01' + interval '1 month - 1 second' AS "Dec 31";
|
2003-03-20 07:03:00 +01:00
|
|
|
SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '106000000 days' AS "Feb 23, 285506";
|
|
|
|
SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '107000000 days' AS "Jan 20, 288244";
|
|
|
|
SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '109203489 days' AS "Dec 31, 294276";
|
|
|
|
SELECT timestamp without time zone '12/31/294276' - timestamp without time zone '12/23/1999' AS "106751991 Days";
|
2001-09-28 10:00:11 +02:00
|
|
|
|
|
|
|
-- 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
|
|
|
|
SELECT (timestamp without time zone 'today' = (timestamp without time zone 'yesterday' + interval '1 day')) as "True";
|
|
|
|
SELECT (timestamp without time zone 'today' = (timestamp without time zone 'tomorrow' - interval '1 day')) as "True";
|
2011-08-30 17:34:29 +02:00
|
|
|
SELECT (timestamp without time zone 'today 10:30' = (timestamp without time zone 'yesterday' + interval '1 day 10 hr 30 min')) as "True";
|
|
|
|
SELECT (timestamp without time zone '10:30 today' = (timestamp without time zone 'yesterday' + interval '1 day 10 hr 30 min')) as "True";
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT (timestamp without time zone 'tomorrow' = (timestamp without time zone 'yesterday' + interval '2 days')) as "True";
|
2011-08-30 17:34:29 +02:00
|
|
|
SELECT (timestamp without time zone 'tomorrow 16:00:00' = (timestamp without time zone 'today' + interval '1 day 16 hours')) as "True";
|
|
|
|
SELECT (timestamp without time zone '16:00:00 tomorrow' = (timestamp without time zone 'today' + interval '1 day 16 hours')) as "True";
|
|
|
|
SELECT (timestamp without time zone 'yesterday 12:34:56' = (timestamp without time zone 'tomorrow' - interval '2 days - 12:34:56')) as "True";
|
|
|
|
SELECT (timestamp without time zone '12:34:56 yesterday' = (timestamp without time zone 'tomorrow' - interval '2 days - 12:34:56')) as "True";
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT (timestamp without time zone 'tomorrow' > 'now') as "True";
|
|
|
|
|
2001-10-03 07:29:27 +02:00
|
|
|
-- Convert from date and time to timestamp
|
|
|
|
-- This test used to be timestamp(date,time) but no longer allowed by grammar
|
|
|
|
-- to enable support for SQL99 timestamp type syntax.
|
|
|
|
SELECT date '1994-01-01' + time '11:00' AS "Jan_01_1994_11am";
|
|
|
|
SELECT date '1994-01-01' + time '10:00' AS "Jan_01_1994_10am";
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 23:35:25 +02:00
|
|
|
SELECT date '1994-01-01' + timetz '11:00-5' AS "Jan_01_1994_8am";
|
|
|
|
SELECT timestamptz(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_8am";
|
2001-09-28 10:00:11 +02:00
|
|
|
|
|
|
|
SELECT '' AS "64", d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL;
|
|
|
|
SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL;
|
|
|
|
|
|
|
|
SELECT timestamp with time zone '1996-03-01' - interval '1 second' AS "Feb 29";
|
|
|
|
SELECT timestamp with time zone '1999-03-01' - interval '1 second' AS "Feb 28";
|
|
|
|
SELECT timestamp with time zone '2000-03-01' - interval '1 second' AS "Feb 29";
|
|
|
|
SELECT timestamp with time zone '1999-12-01' + interval '1 month - 1 second' AS "Dec 31";
|
|
|
|
|
|
|
|
SELECT (timestamp with time zone 'today' = (timestamp with time zone 'yesterday' + interval '1 day')) as "True";
|
|
|
|
SELECT (timestamp with time zone 'today' = (timestamp with time zone 'tomorrow' - interval '1 day')) as "True";
|
|
|
|
SELECT (timestamp with time zone 'tomorrow' = (timestamp with time zone 'yesterday' + interval '2 days')) as "True";
|
|
|
|
SELECT (timestamp with time zone 'tomorrow' > 'now') as "True";
|
|
|
|
|
2005-07-30 16:52:04 +02:00
|
|
|
-- timestamp with time zone, interval arithmetic around DST change
|
|
|
|
SET TIME ZONE 'CST7CDT';
|
|
|
|
SELECT timestamp with time zone '2005-04-02 12:00-07' + interval '1 day' as "Apr 3, 12:00";
|
|
|
|
SELECT timestamp with time zone '2005-04-02 12:00-07' + interval '24 hours' as "Apr 3, 13:00";
|
|
|
|
SELECT timestamp with time zone '2005-04-03 12:00-06' - interval '1 day' as "Apr 2, 12:00";
|
|
|
|
SELECT timestamp with time zone '2005-04-03 12:00-06' - interval '24 hours' as "Apr 2, 11:00";
|
|
|
|
RESET TIME ZONE;
|
|
|
|
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT timestamptz(date '1994-01-01', time '11:00') AS "Jan_01_1994_10am";
|
|
|
|
SELECT timestamptz(date '1994-01-01', time '10:00') AS "Jan_01_1994_9am";
|
|
|
|
SELECT timestamptz(date '1994-01-01', time with time zone '11:00-8') AS "Jan_01_1994_11am";
|
|
|
|
SELECT timestamptz(date '1994-01-01', time with time zone '10:00-8') AS "Jan_01_1994_10am";
|
|
|
|
SELECT timestamptz(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_8am";
|
|
|
|
|
|
|
|
SELECT '' AS "64", d1 + interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL;
|
|
|
|
SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL;
|
2000-01-05 07:07:58 +01:00
|
|
|
|
2000-12-03 15:51:12 +01:00
|
|
|
--
|
|
|
|
-- time, interval arithmetic
|
|
|
|
--
|
|
|
|
|
|
|
|
SELECT CAST(time '01:02' AS interval) AS "+01:02";
|
|
|
|
SELECT CAST(interval '02:03' AS time) AS "02:03:00";
|
|
|
|
SELECT time '01:30' + interval '02:01' AS "03:31:00";
|
|
|
|
SELECT time '01:30' - interval '02:01' AS "23:29:00";
|
|
|
|
SELECT time '02:30' + interval '36:01' AS "14:31:00";
|
|
|
|
SELECT time '03:30' + interval '1 month 04:01' AS "07:31:00";
|
|
|
|
SELECT CAST(time with time zone '01:02-08' AS interval) AS "+00:01";
|
|
|
|
SELECT CAST(interval '02:03' AS time with time zone) AS "02:03:00-08";
|
|
|
|
SELECT time with time zone '01:30-08' - interval '02:01' AS "23:29:00-08";
|
|
|
|
SELECT time with time zone '02:30-08' + interval '36:01' AS "14:31:00-08";
|
|
|
|
|
2001-04-04 22:03:11 +02:00
|
|
|
-- These two tests cannot be used because they default to current timezone,
|
|
|
|
-- which may be either -08 or -07 depending on the time of year.
|
|
|
|
-- SELECT time with time zone '01:30' + interval '02:01' AS "03:31:00-08";
|
|
|
|
-- SELECT time with time zone '03:30' + interval '1 month 04:01' AS "07:31:00-08";
|
2001-04-06 07:50:29 +02:00
|
|
|
-- Try the following two tests instead, as a poor substitute
|
|
|
|
|
2006-04-02 21:39:54 +02:00
|
|
|
SELECT CAST(CAST(date 'today' + time with time zone '05:30'
|
|
|
|
+ interval '02:01' AS time with time zone) AS time) AS "07:31:00";
|
2001-04-06 07:50:29 +02:00
|
|
|
|
2001-11-06 17:31:13 +01:00
|
|
|
SELECT CAST(cast(date 'today' + time with time zone '03:30'
|
2001-09-29 17:17:42 +02:00
|
|
|
+ interval '1 month 04:01' as timestamp without time zone) AS time) AS "07:31:00";
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2007-07-25 19:22:37 +02:00
|
|
|
SELECT t.d1 AS t, i.f1 AS i, t.d1 + i.f1 AS "add", t.d1 - i.f1 AS "subtract"
|
|
|
|
FROM TIMESTAMP_TBL t, INTERVAL_TBL i
|
2000-12-03 15:51:12 +01:00
|
|
|
WHERE t.d1 BETWEEN '1990-01-01' AND '2001-01-01'
|
2007-07-25 19:22:37 +02:00
|
|
|
AND i.f1 BETWEEN '00:00' AND '23:00'
|
|
|
|
ORDER BY 1,2;
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2007-07-25 19:22:37 +02:00
|
|
|
SELECT t.f1 AS t, i.f1 AS i, t.f1 + i.f1 AS "add", t.f1 - i.f1 AS "subtract"
|
|
|
|
FROM TIME_TBL t, INTERVAL_TBL i
|
|
|
|
ORDER BY 1,2;
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2007-07-25 19:22:37 +02:00
|
|
|
SELECT t.f1 AS t, i.f1 AS i, t.f1 + i.f1 AS "add", t.f1 - i.f1 AS "subtract"
|
|
|
|
FROM TIMETZ_TBL t, INTERVAL_TBL i
|
|
|
|
ORDER BY 1,2;
|
2000-12-03 15:51:12 +01:00
|
|
|
|
|
|
|
-- SQL9x OVERLAPS operator
|
2001-09-28 10:00:11 +02:00
|
|
|
-- test with time zone
|
|
|
|
SELECT (timestamp with time zone '2000-11-27', timestamp with time zone '2000-11-28')
|
|
|
|
OVERLAPS (timestamp with time zone '2000-11-27 12:00', timestamp with time zone '2000-11-30') AS "True";
|
|
|
|
|
|
|
|
SELECT (timestamp with time zone '2000-11-26', timestamp with time zone '2000-11-27')
|
|
|
|
OVERLAPS (timestamp with time zone '2000-11-27 12:00', timestamp with time zone '2000-11-30') AS "False";
|
|
|
|
|
|
|
|
SELECT (timestamp with time zone '2000-11-27', timestamp with time zone '2000-11-28')
|
|
|
|
OVERLAPS (timestamp with time zone '2000-11-27 12:00', interval '1 day') AS "True";
|
|
|
|
|
|
|
|
SELECT (timestamp with time zone '2000-11-27', interval '12 hours')
|
|
|
|
OVERLAPS (timestamp with time zone '2000-11-27 12:00', timestamp with time zone '2000-11-30') AS "False";
|
|
|
|
|
|
|
|
SELECT (timestamp with time zone '2000-11-27', interval '12 hours')
|
|
|
|
OVERLAPS (timestamp with time zone '2000-11-27', interval '12 hours') AS "True";
|
|
|
|
|
|
|
|
SELECT (timestamp with time zone '2000-11-27', interval '12 hours')
|
|
|
|
OVERLAPS (timestamp with time zone '2000-11-27 12:00', interval '12 hours') AS "False";
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
-- test without time zone
|
|
|
|
SELECT (timestamp without time zone '2000-11-27', timestamp without time zone '2000-11-28')
|
|
|
|
OVERLAPS (timestamp without time zone '2000-11-27 12:00', timestamp without time zone '2000-11-30') AS "True";
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT (timestamp without time zone '2000-11-26', timestamp without time zone '2000-11-27')
|
|
|
|
OVERLAPS (timestamp without time zone '2000-11-27 12:00', timestamp without time zone '2000-11-30') AS "False";
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT (timestamp without time zone '2000-11-27', timestamp without time zone '2000-11-28')
|
|
|
|
OVERLAPS (timestamp without time zone '2000-11-27 12:00', interval '1 day') AS "True";
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT (timestamp without time zone '2000-11-27', interval '12 hours')
|
|
|
|
OVERLAPS (timestamp without time zone '2000-11-27 12:00', timestamp without time zone '2000-11-30') AS "False";
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT (timestamp without time zone '2000-11-27', interval '12 hours')
|
|
|
|
OVERLAPS (timestamp without time zone '2000-11-27', interval '12 hours') AS "True";
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT (timestamp without time zone '2000-11-27', interval '12 hours')
|
|
|
|
OVERLAPS (timestamp without time zone '2000-11-27 12:00', interval '12 hours') AS "False";
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
-- test time and interval
|
2000-12-03 15:51:12 +01:00
|
|
|
SELECT (time '00:00', time '01:00')
|
|
|
|
OVERLAPS (time '00:30', time '01:30') AS "True";
|
|
|
|
|
|
|
|
SELECT (time '00:00', interval '1 hour')
|
|
|
|
OVERLAPS (time '00:30', interval '1 hour') AS "True";
|
|
|
|
|
|
|
|
SELECT (time '00:00', interval '1 hour')
|
|
|
|
OVERLAPS (time '01:30', interval '1 hour') AS "False";
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
-- SQL99 seems to want this to be false (and we conform to the spec).
|
|
|
|
-- istm that this *should* return true, on the theory that time
|
|
|
|
-- intervals can wrap around the day boundary - thomas 2001-09-25
|
2000-12-03 15:51:12 +01:00
|
|
|
SELECT (time '00:00', interval '1 hour')
|
2001-09-28 10:00:11 +02:00
|
|
|
OVERLAPS (time '01:30', interval '1 day') AS "False";
|
2000-12-03 15:51:12 +01:00
|
|
|
|
2002-04-21 21:52:18 +02:00
|
|
|
CREATE TABLE TEMP_TIMESTAMP (f1 timestamp with time zone);
|
1997-05-11 17:42:09 +02:00
|
|
|
|
|
|
|
-- get some candidate input values
|
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
INSERT INTO TEMP_TIMESTAMP (f1)
|
|
|
|
SELECT d1 FROM TIMESTAMP_TBL
|
1997-05-11 17:42:09 +02:00
|
|
|
WHERE d1 BETWEEN '13-jun-1957' AND '1-jan-1997'
|
|
|
|
OR d1 BETWEEN '1-jan-1999' AND '1-jan-2010';
|
|
|
|
|
2001-10-03 07:29:27 +02:00
|
|
|
SELECT '' AS "16", f1 AS "timestamp"
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
FROM TEMP_TIMESTAMP
|
2001-10-03 07:29:27 +02:00
|
|
|
ORDER BY "timestamp";
|
1997-05-11 17:42:09 +02:00
|
|
|
|
2001-10-18 19:30:21 +02:00
|
|
|
SELECT '' AS "160", d.f1 AS "timestamp", t.f1 AS "interval", d.f1 + t.f1 AS plus
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
FROM TEMP_TIMESTAMP d, INTERVAL_TBL t
|
2001-10-18 19:30:21 +02:00
|
|
|
ORDER BY plus, "timestamp", "interval";
|
1997-05-11 17:42:09 +02:00
|
|
|
|
2001-10-18 19:30:21 +02:00
|
|
|
SELECT '' AS "160", d.f1 AS "timestamp", t.f1 AS "interval", d.f1 - t.f1 AS minus
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
FROM TEMP_TIMESTAMP d, INTERVAL_TBL t
|
1997-05-11 17:42:09 +02:00
|
|
|
WHERE isfinite(d.f1)
|
2001-10-18 19:30:21 +02:00
|
|
|
ORDER BY minus, "timestamp", "interval";
|
1997-05-11 17:42:09 +02:00
|
|
|
|
2002-04-21 21:52:18 +02:00
|
|
|
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
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
FROM TEMP_TIMESTAMP d
|
1997-05-11 17:42:09 +02:00
|
|
|
ORDER BY difference;
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS "226", d1.f1 AS timestamp1, d2.f1 AS timestamp2, d1.f1 - d2.f1 AS difference
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
FROM TEMP_TIMESTAMP d1, TEMP_TIMESTAMP d2
|
|
|
|
ORDER BY timestamp1, timestamp2, difference;
|
1997-05-11 17:42:09 +02:00
|
|
|
|
|
|
|
--
|
|
|
|
-- abstime, reltime arithmetic
|
|
|
|
--
|
|
|
|
|
2000-09-14 17:55:07 +02:00
|
|
|
SELECT '' AS ten, ABSTIME_TBL.f1 AS abstime, RELTIME_TBL.f1 AS reltime
|
2005-04-07 03:51:41 +02:00
|
|
|
FROM ABSTIME_TBL, RELTIME_TBL
|
2001-09-28 10:00:11 +02:00
|
|
|
WHERE (ABSTIME_TBL.f1 + RELTIME_TBL.f1) < abstime 'Jan 14 14:00:00 1971'
|
2000-09-14 17:55:07 +02:00
|
|
|
ORDER BY abstime, reltime;
|
|
|
|
|
|
|
|
-- these four queries should return the same answer
|
|
|
|
-- the "infinity" and "-infinity" tuples in ABSTIME_TBL cannot be added and
|
|
|
|
-- therefore, should not show up in the results.
|
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS three, * FROM ABSTIME_TBL
|
2000-09-14 17:55:07 +02:00
|
|
|
WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year') -- +3 years
|
2001-09-28 10:00:11 +02:00
|
|
|
< abstime 'Jan 14 14:00:00 1977';
|
2000-09-14 17:55:07 +02:00
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS three, * FROM ABSTIME_TBL
|
2000-09-14 17:55:07 +02:00
|
|
|
WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year ago') -- -3 years
|
2001-09-28 10:00:11 +02:00
|
|
|
< abstime 'Jan 14 14:00:00 1971';
|
2000-09-14 17:55:07 +02:00
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS three, * FROM ABSTIME_TBL
|
2000-09-14 17:55:07 +02:00
|
|
|
WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year') -- -(+3) years
|
2001-09-28 10:00:11 +02:00
|
|
|
< abstime 'Jan 14 14:00:00 1971';
|
2000-09-14 17:55:07 +02:00
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS three, * FROM ABSTIME_TBL
|
2000-09-14 17:55:07 +02:00
|
|
|
WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year ago') -- -(-3) years
|
2001-09-28 10:00:11 +02:00
|
|
|
< abstime 'Jan 14 14:00:00 1977';
|
1997-05-11 17:42:09 +02:00
|
|
|
|
|
|
|
--
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
-- Conversions
|
1997-05-11 17:42:09 +02:00
|
|
|
--
|
|
|
|
|
2001-10-03 07:29:27 +02:00
|
|
|
SELECT '' AS "16", f1 AS "timestamp", date(f1) AS date
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
FROM TEMP_TIMESTAMP
|
2001-11-21 19:27:25 +01:00
|
|
|
WHERE f1 <> timestamp 'now'
|
2001-10-03 07:29:27 +02:00
|
|
|
ORDER BY date, "timestamp";
|
1997-05-11 17:42:09 +02:00
|
|
|
|
2001-10-03 07:29:27 +02:00
|
|
|
SELECT '' AS "16", f1 AS "timestamp", abstime(f1) AS abstime
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
FROM TEMP_TIMESTAMP
|
1997-05-11 17:42:09 +02:00
|
|
|
ORDER BY abstime;
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS four, f1 AS abstime, date(f1) AS date
|
1997-05-11 17:42:09 +02:00
|
|
|
FROM ABSTIME_TBL
|
2001-11-21 19:27:25 +01:00
|
|
|
WHERE isfinite(f1) AND f1 <> abstime 'now'
|
2000-03-16 18:03:41 +01:00
|
|
|
ORDER BY date, abstime;
|
1997-05-11 17:42:09 +02:00
|
|
|
|
2001-10-03 07:29:27 +02:00
|
|
|
SELECT '' AS two, d1 AS "timestamp", abstime(d1) AS abstime
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
FROM TIMESTAMP_TBL WHERE NOT isfinite(d1);
|
1997-05-11 17:42:09 +02:00
|
|
|
|
2001-10-03 07:29:27 +02:00
|
|
|
SELECT '' AS three, f1 as abstime, cast(f1 as timestamp) AS "timestamp"
|
1997-05-11 17:42:09 +02:00
|
|
|
FROM ABSTIME_TBL WHERE NOT isfinite(f1);
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS ten, f1 AS interval, reltime(f1) AS reltime
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
FROM INTERVAL_TBL;
|
1997-05-11 17:42:09 +02:00
|
|
|
|
2001-10-18 19:30:21 +02:00
|
|
|
SELECT '' AS six, f1 as reltime, CAST(f1 AS interval) AS interval
|
1997-05-11 17:42:09 +02:00
|
|
|
FROM RELTIME_TBL;
|
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
DROP TABLE TEMP_TIMESTAMP;
|
1997-05-11 17:42:09 +02:00
|
|
|
|
1997-06-23 17:05:52 +02:00
|
|
|
--
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
-- Formats
|
1997-06-23 17:05:52 +02:00
|
|
|
--
|
|
|
|
|
|
|
|
SET DateStyle TO 'US,Postgres';
|
|
|
|
|
|
|
|
SHOW DateStyle;
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
|
1997-06-23 17:05:52 +02:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS seven, f1 AS us_postgres FROM ABSTIME_TBL;
|
1997-07-01 02:34:34 +02:00
|
|
|
|
|
|
|
SET DateStyle TO 'US,ISO';
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS "64", d1 AS us_iso FROM TIMESTAMP_TBL;
|
1997-07-01 02:34:34 +02:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS seven, f1 AS us_iso FROM ABSTIME_TBL;
|
1997-07-01 02:34:34 +02:00
|
|
|
|
|
|
|
SET DateStyle TO 'US,SQL';
|
|
|
|
|
|
|
|
SHOW DateStyle;
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
|
1997-07-01 02:34:34 +02:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
|
1997-07-01 02:34:34 +02:00
|
|
|
|
|
|
|
SET DateStyle TO 'European,Postgres';
|
|
|
|
|
|
|
|
SHOW DateStyle;
|
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957');
|
1997-07-01 02:34:34 +02:00
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
SELECT count(*) as one FROM TIMESTAMP_TBL WHERE d1 = 'Jun 13 1957';
|
1997-07-01 02:34:34 +02:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS "65", d1 AS european_postgres FROM TIMESTAMP_TBL;
|
1997-07-01 02:34:34 +02:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
|
1997-07-01 02:34:34 +02:00
|
|
|
|
|
|
|
SET DateStyle TO 'European,ISO';
|
|
|
|
|
|
|
|
SHOW DateStyle;
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
|
1997-07-01 02:34:34 +02:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
|
1997-07-01 02:34:34 +02:00
|
|
|
|
|
|
|
SET DateStyle TO 'European,SQL';
|
|
|
|
|
|
|
|
SHOW DateStyle;
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
|
1997-06-23 17:05:52 +02:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
SELECT '' AS seven, f1 AS european_sql FROM ABSTIME_TBL;
|
1997-06-23 17:05:52 +02:00
|
|
|
|
|
|
|
RESET DateStyle;
|
2008-09-11 19:32:34 +02:00
|
|
|
|
|
|
|
--
|
|
|
|
-- to_timestamp()
|
|
|
|
--
|
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('97/2/16 8:14:30', 'FMYYYY/FMMM/FMDD FMHH:FMMI:FMSS');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('1985 January 12', 'YYYY FMMonth DD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('My birthday-> Year: 1976, Month: May, Day: 16',
|
|
|
|
'"My birthday-> Year" YYYY, "Month:" FMMonth, "Day:" DD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('1,582nd VIII 21', 'Y,YYYth FMRM DD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('15 "text between quote marks" 98 54 45',
|
|
|
|
E'HH24 "\\text between quote marks\\"" YY MI SS');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('05121445482000', 'MMDDHH24MISSYYYY');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('2000January09Sunday', 'YYYYFMMonthDDFMDay');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('97/Feb/16', 'YYMonDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('19971116', 'YYYYMMDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('20000-1116', 'YYYY-MMDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('9-1116', 'Y-MMDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('95-1116', 'YY-MMDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('995-1116', 'YYY-MMDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('2005426', 'YYYYWWD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('2005300', 'YYYYDDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('2005527', 'IYYYIWID');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('005527', 'IYYIWID');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('05527', 'IYIWID');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('5527', 'IIWID');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('2005364', 'IYYYIDDD');
|
|
|
|
|
|
|
|
SELECT to_timestamp('20050302', 'YYYYMMDD');
|
|
|
|
|
|
|
|
SELECT to_timestamp('2005 03 02', 'YYYYMMDD');
|
|
|
|
|
|
|
|
SELECT to_timestamp(' 2005 03 02', 'YYYYMMDD');
|
|
|
|
|
|
|
|
SELECT to_timestamp(' 20050302', 'YYYYMMDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
2014-01-20 19:45:51 +01:00
|
|
|
--
|
|
|
|
-- Check handling of multiple spaces in format and/or input
|
|
|
|
--
|
|
|
|
|
|
|
|
SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS');
|
|
|
|
SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS');
|
|
|
|
SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS');
|
|
|
|
|
|
|
|
SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS');
|
|
|
|
SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS');
|
|
|
|
SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS');
|
|
|
|
|
|
|
|
SELECT to_date('2011 12 18', 'YYYY MM DD');
|
|
|
|
SELECT to_date('2011 12 18', 'YYYY MM DD');
|
|
|
|
SELECT to_date('2011 12 18', 'YYYY MM DD');
|
|
|
|
|
|
|
|
SELECT to_date('2011 12 18', 'YYYY MM DD');
|
|
|
|
SELECT to_date('2011 12 18', 'YYYY MM DD');
|
|
|
|
SELECT to_date('2011 12 18', 'YYYY MM DD');
|
|
|
|
|
2008-09-11 19:32:34 +02:00
|
|
|
--
|
|
|
|
-- Check errors for some incorrect usages of to_timestamp()
|
|
|
|
--
|
|
|
|
|
|
|
|
-- Mixture of date conventions (ISO week and Gregorian):
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('2005527', 'YYYYIWID');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
|
|
|
-- Insufficient characters in the source string:
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('19971', 'YYYYMMDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
|
|
|
-- Insufficient digit characters for a single node:
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('19971)24', 'YYYYMMDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
|
|
|
-- Value clobbering:
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('1997-11-Jan-16', 'YYYY-MM-Mon-DD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
|
|
|
-- Non-numeric input:
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('199711xy', 'YYYYMMDD');
|
2008-09-11 19:32:34 +02:00
|
|
|
|
|
|
|
-- Input that doesn't fit in an int:
|
2009-06-22 19:54:30 +02:00
|
|
|
SELECT to_timestamp('10000000000', 'FMYYYY');
|
Fix some odd behaviors when using a SQL-style simple GMT offset timezone.
Formerly, when using a SQL-spec timezone setting with a fixed GMT offset
(called a "brute force" timezone in the code), the session_timezone
variable was not updated to match the nominal timezone; rather, all code
was expected to ignore session_timezone if HasCTZSet was true. This is
of course obviously fragile, though a search of the code finds only
timeofday() failing to honor the rule. A bigger problem was that
DetermineTimeZoneOffset() supposed that if its pg_tz parameter was
pointer-equal to session_timezone, then HasCTZSet should override the
parameter. This would cause datetime input containing an explicit zone
name to be treated as referencing the brute-force zone instead, if the
zone name happened to match the session timezone that had prevailed
before installing the brute-force zone setting (as reported in bug #8572).
The same malady could affect AT TIME ZONE operators.
To fix, set up session_timezone so that it matches the brute-force zone
specification, which we can do using the POSIX timezone definition syntax
"<abbrev>offset", and get rid of the bogus lookaside check in
DetermineTimeZoneOffset(). Aside from fixing the erroneous behavior in
datetime parsing and AT TIME ZONE, this will cause the timeofday() function
to print its result in the user-requested time zone rather than some
previously-set zone. It might also affect results in third-party
extensions, if there are any that make use of session_timezone without
considering HasCTZSet, but in all cases the new behavior should be saner
than before.
Back-patch to all supported branches.
2013-11-01 17:13:18 +01:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Check behavior with SQL-style fixed-GMT-offset time zone (cf bug #8572)
|
|
|
|
--
|
|
|
|
|
|
|
|
SET TIME ZONE 'America/New_York';
|
|
|
|
SET TIME ZONE '-1.5';
|
|
|
|
|
|
|
|
SHOW TIME ZONE;
|
|
|
|
|
|
|
|
SELECT '2012-12-12 12:00'::timestamptz;
|
|
|
|
SELECT '2012-12-12 12:00 America/New_York'::timestamptz;
|
|
|
|
|
|
|
|
SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ');
|
|
|
|
|
|
|
|
RESET TIME ZONE;
|