Please find attached two patches for documentation and regression tests
for the usage of full time zone names. Joachim Wieland
This commit is contained in:
parent
956cbeb7ef
commit
a77275fe3b
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.168 2006/06/18 15:38:35 petere Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.169 2006/07/06 01:46:37 momjian Exp $ -->
|
||||
|
||||
<chapter id="datatype">
|
||||
<title id="datatype-title">Data Types</title>
|
||||
@ -1602,7 +1602,12 @@ SELECT b, char_length(b) FROM test2;
|
||||
linkend="datatype-datetime-time-table">
|
||||
and <xref linkend="datatype-timezone-table">.) If a time zone is
|
||||
specified in the input for <type>time without time zone</type>,
|
||||
it is silently ignored.
|
||||
it is silently ignored. You can also always specify a date but it will
|
||||
be ignored except for when you use a full time zone name like
|
||||
<literal>America/New_York</literal>. In this case specifying the date
|
||||
is compulsory in order to tell which time zone offset should be
|
||||
applied. It will be applied whatever time zone offset was valid at that
|
||||
date and time at the specified place.
|
||||
</para>
|
||||
|
||||
<table id="datatype-datetime-time-table">
|
||||
@ -1659,6 +1664,10 @@ SELECT b, char_length(b) FROM test2;
|
||||
<entry><literal>04:05:06 PST</literal></entry>
|
||||
<entry>time zone specified by name</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>2003-04-12 04:05:06 America/New_York</literal></entry>
|
||||
<entry>time zone specified by full name</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
@ -1677,6 +1686,10 @@ SELECT b, char_length(b) FROM test2;
|
||||
<entry><literal>PST</literal></entry>
|
||||
<entry>Pacific Standard Time</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>America/New_York</literal></entry>
|
||||
<entry>Full time zone name</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>-8:00</literal></entry>
|
||||
<entry>ISO-8601 offset for PST</entry>
|
||||
@ -1739,8 +1752,12 @@ SELECT b, char_length(b) FROM test2;
|
||||
</programlisting>
|
||||
|
||||
are valid values, which follow the <acronym>ISO</acronym> 8601
|
||||
standard. In addition, the wide-spread format
|
||||
standard. You can also specify the full time zone name as in
|
||||
<programlisting>
|
||||
1999-01-08 04:05:06 America/New_York
|
||||
</programlisting>
|
||||
|
||||
In addition, the wide-spread format
|
||||
<programlisting>
|
||||
January 8 04:05:06 1999 PST
|
||||
</programlisting>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/datetime.sgml,v 2.49 2006/04/23 03:39:50 momjian Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/datetime.sgml,v 2.50 2006/07/06 01:46:37 momjian Exp $ -->
|
||||
|
||||
<appendix id="datetime-appendix">
|
||||
<title>Date/Time Support</title>
|
||||
@ -46,7 +46,9 @@
|
||||
<para>
|
||||
If the numeric token contains a dash (<literal>-</>), slash
|
||||
(<literal>/</>), or two or more dots (<literal>.</>), this is
|
||||
a date string which may have a text month.
|
||||
a date string which may have a text month. In case of a slash
|
||||
(<literal>/</>) it can also be a full time zone name like
|
||||
<literal>America/New_York</>.
|
||||
</para>
|
||||
</step>
|
||||
|
||||
@ -359,7 +361,8 @@
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
<xref linkend="datetime-timezone-input-table"> shows the time zone
|
||||
<xref linkend="datetime-timezone-input-table"> and
|
||||
<xref linkend="datetime-timezone-full-names-table"> show the time zone
|
||||
abbreviations recognized by <productname>PostgreSQL</productname>
|
||||
in date/time input values. Note that these names are <emphasis>not</>
|
||||
necessarily used for date/time output — output is driven by the
|
||||
@ -983,13 +986,15 @@
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
<xref linkend="datetime-timezone-set-table"> shows the time zone
|
||||
<xref linkend="datetime-timezone-full-names-table"> shows the time zone
|
||||
names recognized by <productname>PostgreSQL</productname> as valid
|
||||
settings for the <xref linkend="guc-timezone"> parameter. Note that
|
||||
these names are conceptually as well as practically different from
|
||||
the names shown in <xref linkend="datetime-timezone-input-table">:
|
||||
most of these names imply a local daylight-savings time rule, whereas
|
||||
the former names each represent just a fixed offset from UTC.
|
||||
the former names each represent just a fixed offset from UTC. That's why
|
||||
you always have to specify a date if you want to use these time zone
|
||||
names in <type>timetz</> values.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@ -998,8 +1003,8 @@
|
||||
by the name of the principal city of the zone.
|
||||
</para>
|
||||
|
||||
<table id="datetime-timezone-set-table">
|
||||
<title>Time Zone Names for Setting <varname>timezone</></title>
|
||||
<table id="datetime-timezone-full-names-table">
|
||||
<title>Time Zone Names for date/time input values and for setting <varname>timezone</></title>
|
||||
<tgroup cols="1">
|
||||
<thead>
|
||||
<row>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.323 2006/06/19 16:13:01 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.324 2006/07/06 01:46:37 momjian Exp $ -->
|
||||
|
||||
<chapter id="functions">
|
||||
<title>Functions and Operators</title>
|
||||
@ -6099,7 +6099,7 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
|
||||
specified either as a text string (e.g., <literal>'PST'</literal>)
|
||||
or as an interval (e.g., <literal>INTERVAL '-08:00'</literal>).
|
||||
In the text case, the available zone names are those shown in either
|
||||
<xref linkend="datetime-timezone-set-table"> or
|
||||
<xref linkend="datetime-timezone-full-names-table"> or
|
||||
<xref linkend="datetime-timezone-input-table">.
|
||||
</para>
|
||||
|
||||
|
@ -450,6 +450,7 @@ SELECT '' AS "64", d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL;
|
||||
| Tue Feb 10 17:32:01 1998
|
||||
| Tue Feb 10 17:32:01 1998
|
||||
| Tue Feb 10 17:32:01 1998
|
||||
| Tue Feb 10 14:32:01 1998
|
||||
| Wed Jun 10 18:32:01 1998
|
||||
| Tue Feb 10 17:32:01 1998
|
||||
| Wed Feb 11 17:32:01 1998
|
||||
@ -481,7 +482,7 @@ SELECT '' AS "64", d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL;
|
||||
| Mon Jan 01 17:32:01 2001
|
||||
| Mon Dec 31 17:32:01 2001
|
||||
| Tue Jan 01 17:32:01 2002
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL;
|
||||
64 | one_year
|
||||
@ -519,6 +520,7 @@ SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL;
|
||||
| Sat Feb 10 17:32:01 1996
|
||||
| Sat Feb 10 17:32:01 1996
|
||||
| Sat Feb 10 17:32:01 1996
|
||||
| Sat Feb 10 14:32:01 1996
|
||||
| Mon Jun 10 18:32:01 1996
|
||||
| Sat Feb 10 17:32:01 1996
|
||||
| Sun Feb 11 17:32:01 1996
|
||||
@ -550,7 +552,7 @@ SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL;
|
||||
| Fri Jan 01 17:32:01 1999
|
||||
| Fri Dec 31 17:32:01 1999
|
||||
| Sat Jan 01 17:32:01 2000
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT timestamp with time zone '1996-03-01' - interval '1 second' AS "Feb 29";
|
||||
Feb 29
|
||||
@ -693,6 +695,8 @@ SELECT '' AS "64", d1 + interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL;
|
||||
| Tue Feb 10 09:32:01 1998 PST
|
||||
| Tue Feb 10 09:32:01 1998 PST
|
||||
| Tue Feb 10 09:32:01 1998 PST
|
||||
| Tue Feb 10 14:32:01 1998 PST
|
||||
| Fri Jul 10 14:32:01 1998 PDT
|
||||
| Wed Jun 10 18:32:01 1998 PDT
|
||||
| Tue Feb 10 17:32:01 1998 PST
|
||||
| Wed Feb 11 17:32:01 1998 PST
|
||||
@ -724,7 +728,7 @@ SELECT '' AS "64", d1 + interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL;
|
||||
| Mon Jan 01 17:32:01 2001 PST
|
||||
| Mon Dec 31 17:32:01 2001 PST
|
||||
| Tue Jan 01 17:32:01 2002 PST
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL;
|
||||
64 | one_year
|
||||
@ -762,6 +766,8 @@ SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL;
|
||||
| Sat Feb 10 09:32:01 1996 PST
|
||||
| Sat Feb 10 09:32:01 1996 PST
|
||||
| Sat Feb 10 09:32:01 1996 PST
|
||||
| Sat Feb 10 14:32:01 1996 PST
|
||||
| Wed Jul 10 14:32:01 1996 PDT
|
||||
| Mon Jun 10 18:32:01 1996 PDT
|
||||
| Sat Feb 10 17:32:01 1996 PST
|
||||
| Sun Feb 11 17:32:01 1996 PST
|
||||
@ -793,7 +799,7 @@ SELECT '' AS "64", d1 - interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL;
|
||||
| Fri Jan 01 17:32:01 1999 PST
|
||||
| Fri Dec 31 17:32:01 1999 PST
|
||||
| Sat Jan 01 17:32:01 2000 PST
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
--
|
||||
-- time, interval arithmetic
|
||||
@ -932,6 +938,8 @@ SELECT t.d1 + i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
|
||||
Mon Feb 10 22:32:01 1997
|
||||
Mon Feb 10 17:33:01 1997
|
||||
Mon Feb 10 22:32:01 1997
|
||||
Mon Feb 10 14:33:01 1997
|
||||
Mon Feb 10 19:32:01 1997
|
||||
Tue Jun 10 18:33:01 1997
|
||||
Tue Jun 10 23:32:01 1997
|
||||
Mon Feb 10 17:33:01 1997
|
||||
@ -976,7 +984,7 @@ SELECT t.d1 + i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
|
||||
Sat Jan 01 22:32:01 2000
|
||||
Sun Dec 31 17:33:01 2000
|
||||
Sun Dec 31 22:32:01 2000
|
||||
(102 rows)
|
||||
(104 rows)
|
||||
|
||||
SELECT t.d1 - i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
|
||||
WHERE t.d1 BETWEEN '1990-01-01' AND '2001-01-01'
|
||||
@ -1041,6 +1049,8 @@ SELECT t.d1 - i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
|
||||
Mon Feb 10 12:32:01 1997
|
||||
Mon Feb 10 17:31:01 1997
|
||||
Mon Feb 10 12:32:01 1997
|
||||
Mon Feb 10 14:31:01 1997
|
||||
Mon Feb 10 09:32:01 1997
|
||||
Tue Jun 10 18:31:01 1997
|
||||
Tue Jun 10 13:32:01 1997
|
||||
Mon Feb 10 17:31:01 1997
|
||||
@ -1085,7 +1095,7 @@ SELECT t.d1 - i.f1 AS "102" FROM TIMESTAMP_TBL t, INTERVAL_TBL i
|
||||
Sat Jan 01 12:32:01 2000
|
||||
Sun Dec 31 17:31:01 2000
|
||||
Sun Dec 31 12:32:01 2000
|
||||
(102 rows)
|
||||
(104 rows)
|
||||
|
||||
SELECT t.f1 + i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
80
|
||||
@ -1170,7 +1180,27 @@ SELECT t.f1 + i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
23:59:59.99
|
||||
23:59:59.99
|
||||
11:59:59.99
|
||||
(80 rows)
|
||||
15:37:39
|
||||
20:36:39
|
||||
15:36:39
|
||||
15:36:39
|
||||
15:36:39
|
||||
15:36:25
|
||||
17:39:43
|
||||
15:36:39
|
||||
15:36:39
|
||||
03:36:39
|
||||
15:37:39
|
||||
20:36:39
|
||||
15:36:39
|
||||
15:36:39
|
||||
15:36:39
|
||||
15:36:25
|
||||
17:39:43
|
||||
15:36:39
|
||||
15:36:39
|
||||
03:36:39
|
||||
(100 rows)
|
||||
|
||||
SELECT t.f1 - i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
80
|
||||
@ -1255,7 +1285,27 @@ SELECT t.f1 - i.f1 AS "80" FROM TIME_TBL t, INTERVAL_TBL i;
|
||||
23:59:59.99
|
||||
23:59:59.99
|
||||
11:59:59.99
|
||||
(80 rows)
|
||||
15:35:39
|
||||
10:36:39
|
||||
15:36:39
|
||||
15:36:39
|
||||
15:36:39
|
||||
15:36:53
|
||||
13:33:35
|
||||
15:36:39
|
||||
15:36:39
|
||||
03:36:39
|
||||
15:35:39
|
||||
10:36:39
|
||||
15:36:39
|
||||
15:36:39
|
||||
15:36:39
|
||||
15:36:53
|
||||
13:33:35
|
||||
15:36:39
|
||||
15:36:39
|
||||
03:36:39
|
||||
(100 rows)
|
||||
|
||||
SELECT t.f1 + i.f1 AS "100" FROM TIMETZ_TBL t, INTERVAL_TBL i;
|
||||
100
|
||||
@ -1360,7 +1410,27 @@ SELECT t.f1 + i.f1 AS "100" FROM TIMETZ_TBL t, INTERVAL_TBL i;
|
||||
23:59:59.99-07
|
||||
23:59:59.99-07
|
||||
11:59:59.99-07
|
||||
(100 rows)
|
||||
15:37:39-05
|
||||
20:36:39-05
|
||||
15:36:39-05
|
||||
15:36:39-05
|
||||
15:36:39-05
|
||||
15:36:25-05
|
||||
17:39:43-05
|
||||
15:36:39-05
|
||||
15:36:39-05
|
||||
03:36:39-05
|
||||
15:37:39-04
|
||||
20:36:39-04
|
||||
15:36:39-04
|
||||
15:36:39-04
|
||||
15:36:39-04
|
||||
15:36:25-04
|
||||
17:39:43-04
|
||||
15:36:39-04
|
||||
15:36:39-04
|
||||
03:36:39-04
|
||||
(120 rows)
|
||||
|
||||
SELECT t.f1 - i.f1 AS "100" FROM TIMETZ_TBL t, INTERVAL_TBL i;
|
||||
100
|
||||
@ -1465,7 +1535,27 @@ SELECT t.f1 - i.f1 AS "100" FROM TIMETZ_TBL t, INTERVAL_TBL i;
|
||||
23:59:59.99-07
|
||||
23:59:59.99-07
|
||||
11:59:59.99-07
|
||||
(100 rows)
|
||||
15:35:39-05
|
||||
10:36:39-05
|
||||
15:36:39-05
|
||||
15:36:39-05
|
||||
15:36:39-05
|
||||
15:36:53-05
|
||||
13:33:35-05
|
||||
15:36:39-05
|
||||
15:36:39-05
|
||||
03:36:39-05
|
||||
15:35:39-04
|
||||
10:36:39-04
|
||||
15:36:39-04
|
||||
15:36:39-04
|
||||
15:36:39-04
|
||||
15:36:53-04
|
||||
13:33:35-04
|
||||
15:36:39-04
|
||||
15:36:39-04
|
||||
03:36:39-04
|
||||
(120 rows)
|
||||
|
||||
-- SQL9x OVERLAPS operator
|
||||
-- test with time zone
|
||||
@ -2450,6 +2540,7 @@ SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 14:32:01 1997
|
||||
| Tue Jun 10 18:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Tue Feb 11 17:32:01 1997
|
||||
@ -2481,7 +2572,7 @@ SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
|
||||
| Sat Jan 01 17:32:01 2000
|
||||
| Sun Dec 31 17:32:01 2000
|
||||
| Mon Jan 01 17:32:01 2001
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS seven, f1 AS us_postgres FROM ABSTIME_TBL;
|
||||
seven | us_postgres
|
||||
@ -2532,6 +2623,7 @@ SELECT '' AS "64", d1 AS us_iso FROM TIMESTAMP_TBL;
|
||||
| 1997-02-10 17:32:01
|
||||
| 1997-02-10 17:32:01
|
||||
| 1997-02-10 17:32:01
|
||||
| 1997-02-10 14:32:01
|
||||
| 1997-06-10 18:32:01
|
||||
| 1997-02-10 17:32:01
|
||||
| 1997-02-11 17:32:01
|
||||
@ -2563,7 +2655,7 @@ SELECT '' AS "64", d1 AS us_iso FROM TIMESTAMP_TBL;
|
||||
| 2000-01-01 17:32:01
|
||||
| 2000-12-31 17:32:01
|
||||
| 2001-01-01 17:32:01
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS seven, f1 AS us_iso FROM ABSTIME_TBL;
|
||||
seven | us_iso
|
||||
@ -2620,6 +2712,7 @@ SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
|
||||
| 02/10/1997 17:32:01
|
||||
| 02/10/1997 17:32:01
|
||||
| 02/10/1997 17:32:01
|
||||
| 02/10/1997 14:32:01
|
||||
| 06/10/1997 18:32:01
|
||||
| 02/10/1997 17:32:01
|
||||
| 02/11/1997 17:32:01
|
||||
@ -2651,7 +2744,7 @@ SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
|
||||
| 01/01/2000 17:32:01
|
||||
| 12/31/2000 17:32:01
|
||||
| 01/01/2001 17:32:01
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
|
||||
seven | us_sql
|
||||
@ -2715,6 +2808,7 @@ SELECT '' AS "65", d1 AS european_postgres FROM TIMESTAMP_TBL;
|
||||
| Mon 10 Feb 17:32:01 1997
|
||||
| Mon 10 Feb 17:32:01 1997
|
||||
| Mon 10 Feb 17:32:01 1997
|
||||
| Mon 10 Feb 14:32:01 1997
|
||||
| Tue 10 Jun 18:32:01 1997
|
||||
| Mon 10 Feb 17:32:01 1997
|
||||
| Tue 11 Feb 17:32:01 1997
|
||||
@ -2747,7 +2841,7 @@ SELECT '' AS "65", d1 AS european_postgres FROM TIMESTAMP_TBL;
|
||||
| Sun 31 Dec 17:32:01 2000
|
||||
| Mon 01 Jan 17:32:01 2001
|
||||
| Thu 13 Jun 00:00:00 1957
|
||||
(65 rows)
|
||||
(66 rows)
|
||||
|
||||
SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
|
||||
seven | european_postgres
|
||||
@ -2804,6 +2898,7 @@ SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
|
||||
| 1997-02-10 17:32:01
|
||||
| 1997-02-10 17:32:01
|
||||
| 1997-02-10 17:32:01
|
||||
| 1997-02-10 14:32:01
|
||||
| 1997-06-10 18:32:01
|
||||
| 1997-02-10 17:32:01
|
||||
| 1997-02-11 17:32:01
|
||||
@ -2836,7 +2931,7 @@ SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
|
||||
| 2000-12-31 17:32:01
|
||||
| 2001-01-01 17:32:01
|
||||
| 1957-06-13 00:00:00
|
||||
(65 rows)
|
||||
(66 rows)
|
||||
|
||||
SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
|
||||
seven | european_iso
|
||||
@ -2893,6 +2988,7 @@ SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
|
||||
| 10/02/1997 17:32:01
|
||||
| 10/02/1997 17:32:01
|
||||
| 10/02/1997 17:32:01
|
||||
| 10/02/1997 14:32:01
|
||||
| 10/06/1997 18:32:01
|
||||
| 10/02/1997 17:32:01
|
||||
| 11/02/1997 17:32:01
|
||||
@ -2925,7 +3021,7 @@ SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
|
||||
| 31/12/2000 17:32:01
|
||||
| 01/01/2001 17:32:01
|
||||
| 13/06/1957 00:00:00
|
||||
(65 rows)
|
||||
(66 rows)
|
||||
|
||||
SELECT '' AS seven, f1 AS european_sql FROM ABSTIME_TBL;
|
||||
seven | european_sql
|
||||
|
@ -11,6 +11,11 @@ INSERT INTO TIME_TBL VALUES ('12:00');
|
||||
INSERT INTO TIME_TBL VALUES ('12:01');
|
||||
INSERT INTO TIME_TBL VALUES ('23:59');
|
||||
INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM');
|
||||
INSERT INTO TIME_TBL VALUES ('2003-03-07 15:36:39 America/New_York');
|
||||
INSERT INTO TIME_TBL VALUES ('2003-07-07 15:36:39 America/New_York');
|
||||
-- this should fail (the timezone offset is not known)
|
||||
INSERT INTO TIME_TBL VALUES ('15:36:39 America/New_York');
|
||||
ERROR: invalid input syntax for type time: "15:36:39 America/New_York"
|
||||
SELECT f1 AS "Time" FROM TIME_TBL;
|
||||
Time
|
||||
-------------
|
||||
@ -22,7 +27,9 @@ SELECT f1 AS "Time" FROM TIME_TBL;
|
||||
12:01:00
|
||||
23:59:00
|
||||
23:59:59.99
|
||||
(8 rows)
|
||||
15:36:39
|
||||
15:36:39
|
||||
(10 rows)
|
||||
|
||||
SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07';
|
||||
Three
|
||||
@ -40,7 +47,9 @@ SELECT f1 AS "Five" FROM TIME_TBL WHERE f1 > '05:06:07';
|
||||
12:01:00
|
||||
23:59:00
|
||||
23:59:59.99
|
||||
(5 rows)
|
||||
15:36:39
|
||||
15:36:39
|
||||
(7 rows)
|
||||
|
||||
SELECT f1 AS "None" FROM TIME_TBL WHERE f1 < '00:00';
|
||||
None
|
||||
@ -58,7 +67,9 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00';
|
||||
12:01:00
|
||||
23:59:00
|
||||
23:59:59.99
|
||||
(8 rows)
|
||||
15:36:39
|
||||
15:36:39
|
||||
(10 rows)
|
||||
|
||||
--
|
||||
-- TIME simple math
|
||||
|
@ -102,6 +102,10 @@ INSERT INTO TIMESTAMP_TBL VALUES ('97FEB10 5:32:01PM UTC');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('97/02/10 17:32:01 UTC');
|
||||
reset datestyle;
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('1997.041 17:32:01 UTC');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 America/New_York');
|
||||
-- this fails
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('19970710 173201 America/Does_not_exist');
|
||||
ERROR: time zone "America/Does_not_exist" not recognized
|
||||
-- Check date conversion and date arithmetic
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 18:32:01 PDT');
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997');
|
||||
@ -177,6 +181,7 @@ SELECT '' AS "64", d1 FROM TIMESTAMP_TBL;
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 14:32:01 1997
|
||||
| Tue Jun 10 18:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Tue Feb 11 17:32:01 1997
|
||||
@ -208,7 +213,7 @@ SELECT '' AS "64", d1 FROM TIMESTAMP_TBL;
|
||||
| Sat Jan 01 17:32:01 2000
|
||||
| Sun Dec 31 17:32:01 2000
|
||||
| Mon Jan 01 17:32:01 2001
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
-- Demonstrate functions and operators
|
||||
SELECT '' AS "48", d1 FROM TIMESTAMP_TBL
|
||||
@ -245,6 +250,7 @@ SELECT '' AS "48", d1 FROM TIMESTAMP_TBL
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 14:32:01 1997
|
||||
| Tue Jun 10 18:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Tue Feb 11 17:32:01 1997
|
||||
@ -263,7 +269,7 @@ SELECT '' AS "48", d1 FROM TIMESTAMP_TBL
|
||||
| Sat Jan 01 17:32:01 2000
|
||||
| Sun Dec 31 17:32:01 2000
|
||||
| Mon Jan 01 17:32:01 2001
|
||||
(48 rows)
|
||||
(49 rows)
|
||||
|
||||
SELECT '' AS "15", d1 FROM TIMESTAMP_TBL
|
||||
WHERE d1 < timestamp without time zone '1997-01-02';
|
||||
@ -329,6 +335,7 @@ SELECT '' AS "63", d1 FROM TIMESTAMP_TBL
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 14:32:01 1997
|
||||
| Tue Jun 10 18:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Tue Feb 11 17:32:01 1997
|
||||
@ -360,7 +367,7 @@ SELECT '' AS "63", d1 FROM TIMESTAMP_TBL
|
||||
| Sat Jan 01 17:32:01 2000
|
||||
| Sun Dec 31 17:32:01 2000
|
||||
| Mon Jan 01 17:32:01 2001
|
||||
(63 rows)
|
||||
(64 rows)
|
||||
|
||||
SELECT '' AS "16", d1 FROM TIMESTAMP_TBL
|
||||
WHERE d1 <= timestamp without time zone '1997-01-02';
|
||||
@ -419,6 +426,7 @@ SELECT '' AS "49", d1 FROM TIMESTAMP_TBL
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Mon Feb 10 14:32:01 1997
|
||||
| Tue Jun 10 18:32:01 1997
|
||||
| Mon Feb 10 17:32:01 1997
|
||||
| Tue Feb 11 17:32:01 1997
|
||||
@ -437,7 +445,7 @@ SELECT '' AS "49", d1 FROM TIMESTAMP_TBL
|
||||
| Sat Jan 01 17:32:01 2000
|
||||
| Sun Dec 31 17:32:01 2000
|
||||
| Mon Jan 01 17:32:01 2001
|
||||
(49 rows)
|
||||
(50 rows)
|
||||
|
||||
SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
|
||||
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
|
||||
@ -474,6 +482,7 @@ SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
|
||||
| @ 39 days 17 hours 32 mins 1 sec
|
||||
| @ 39 days 17 hours 32 mins 1 sec
|
||||
| @ 39 days 17 hours 32 mins 1 sec
|
||||
| @ 39 days 14 hours 32 mins 1 sec
|
||||
| @ 159 days 18 hours 32 mins 1 sec
|
||||
| @ 39 days 17 hours 32 mins 1 sec
|
||||
| @ 40 days 17 hours 32 mins 1 sec
|
||||
@ -497,7 +506,7 @@ SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
|
||||
| @ 1094 days 17 hours 32 mins 1 sec
|
||||
| @ 1459 days 17 hours 32 mins 1 sec
|
||||
| @ 1460 days 17 hours 32 mins 1 sec
|
||||
(54 rows)
|
||||
(55 rows)
|
||||
|
||||
SELECT '' AS date_trunc_week, date_trunc( 'week', timestamp '2004-02-29 15:44:17.71393' ) AS week_trunc;
|
||||
date_trunc_week | week_trunc
|
||||
@ -543,6 +552,7 @@ SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
|
||||
| @ 39 days 17 hours 32 mins 1 sec
|
||||
| @ 39 days 17 hours 32 mins 1 sec
|
||||
| @ 39 days 17 hours 32 mins 1 sec
|
||||
| @ 39 days 14 hours 32 mins 1 sec
|
||||
| @ 159 days 18 hours 32 mins 1 sec
|
||||
| @ 39 days 17 hours 32 mins 1 sec
|
||||
| @ 40 days 17 hours 32 mins 1 sec
|
||||
@ -566,7 +576,7 @@ SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
|
||||
| @ 1094 days 17 hours 32 mins 1 sec
|
||||
| @ 1459 days 17 hours 32 mins 1 sec
|
||||
| @ 1460 days 17 hours 32 mins 1 sec
|
||||
(54 rows)
|
||||
(55 rows)
|
||||
|
||||
SELECT '' AS "54", d1 as "timestamp",
|
||||
date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
|
||||
@ -606,6 +616,7 @@ SELECT '' AS "54", d1 as "timestamp",
|
||||
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
|
||||
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
|
||||
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
|
||||
| Mon Feb 10 14:32:01 1997 | 1997 | 2 | 10 | 14 | 32 | 1
|
||||
| Tue Jun 10 18:32:01 1997 | 1997 | 6 | 10 | 18 | 32 | 1
|
||||
| Mon Feb 10 17:32:01 1997 | 1997 | 2 | 10 | 17 | 32 | 1
|
||||
| Tue Feb 11 17:32:01 1997 | 1997 | 2 | 11 | 17 | 32 | 1
|
||||
@ -629,7 +640,7 @@ SELECT '' AS "54", d1 as "timestamp",
|
||||
| Sat Jan 01 17:32:01 2000 | 2000 | 1 | 1 | 17 | 32 | 1
|
||||
| Sun Dec 31 17:32:01 2000 | 2000 | 12 | 31 | 17 | 32 | 1
|
||||
| Mon Jan 01 17:32:01 2001 | 2001 | 1 | 1 | 17 | 32 | 1
|
||||
(54 rows)
|
||||
(55 rows)
|
||||
|
||||
SELECT '' AS "54", d1 as "timestamp",
|
||||
date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
|
||||
@ -668,6 +679,7 @@ SELECT '' AS "54", d1 as "timestamp",
|
||||
| Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000
|
||||
| Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000
|
||||
| Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000
|
||||
| Mon Feb 10 14:32:01 1997 | 1 | 1000 | 1000000
|
||||
| Tue Jun 10 18:32:01 1997 | 2 | 1000 | 1000000
|
||||
| Mon Feb 10 17:32:01 1997 | 1 | 1000 | 1000000
|
||||
| Tue Feb 11 17:32:01 1997 | 1 | 1000 | 1000000
|
||||
@ -691,7 +703,7 @@ SELECT '' AS "54", d1 as "timestamp",
|
||||
| Sat Jan 01 17:32:01 2000 | 1 | 1000 | 1000000
|
||||
| Sun Dec 31 17:32:01 2000 | 4 | 1000 | 1000000
|
||||
| Mon Jan 01 17:32:01 2001 | 1 | 1000 | 1000000
|
||||
(54 rows)
|
||||
(55 rows)
|
||||
|
||||
-- TO_CHAR()
|
||||
SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon')
|
||||
@ -731,6 +743,7 @@ SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM M
|
||||
| MONDAY Monday monday MON Mon mon FEBRUARY February february II FEB Feb feb
|
||||
| MONDAY Monday monday MON Mon mon FEBRUARY February february II FEB Feb feb
|
||||
| MONDAY Monday monday MON Mon mon FEBRUARY February february II FEB Feb feb
|
||||
| MONDAY Monday monday MON Mon mon FEBRUARY February february II FEB Feb feb
|
||||
| TUESDAY Tuesday tuesday TUE Tue tue JUNE June june VI JUN Jun jun
|
||||
| MONDAY Monday monday MON Mon mon FEBRUARY February february II FEB Feb feb
|
||||
| TUESDAY Tuesday tuesday TUE Tue tue FEBRUARY February february II FEB Feb feb
|
||||
@ -762,7 +775,7 @@ SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM M
|
||||
| SATURDAY Saturday saturday SAT Sat sat JANUARY January january I JAN Jan jan
|
||||
| SUNDAY Sunday sunday SUN Sun sun DECEMBER December december XII DEC Dec dec
|
||||
| MONDAY Monday monday MON Mon mon JANUARY January january I JAN Jan jan
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS to_char_2, to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM')
|
||||
FROM TIMESTAMP_TBL;
|
||||
@ -801,6 +814,7 @@ SELECT '' AS to_char_2, to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth F
|
||||
| MONDAY Monday monday FEBRUARY February february II
|
||||
| MONDAY Monday monday FEBRUARY February february II
|
||||
| MONDAY Monday monday FEBRUARY February february II
|
||||
| MONDAY Monday monday FEBRUARY February february II
|
||||
| TUESDAY Tuesday tuesday JUNE June june VI
|
||||
| MONDAY Monday monday FEBRUARY February february II
|
||||
| TUESDAY Tuesday tuesday FEBRUARY February february II
|
||||
@ -832,7 +846,7 @@ SELECT '' AS to_char_2, to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth F
|
||||
| SATURDAY Saturday saturday JANUARY January january I
|
||||
| SUNDAY Sunday sunday DECEMBER December december XII
|
||||
| MONDAY Monday monday JANUARY January january I
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS to_char_3, to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J')
|
||||
FROM TIMESTAMP_TBL;
|
||||
@ -871,6 +885,7 @@ SELECT '' AS to_char_3, to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J')
|
||||
| 1,997 1997 997 97 7 20 1 02 06 041 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 02 06 041 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 02 06 041 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 02 06 041 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 2 06 23 161 10 3 2450610
|
||||
| 1,997 1997 997 97 7 20 1 02 06 041 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 02 06 042 11 3 2450491
|
||||
@ -902,7 +917,7 @@ SELECT '' AS to_char_3, to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J')
|
||||
| 2,000 2000 000 00 0 21 1 01 01 001 01 7 2451545
|
||||
| 2,000 2000 000 00 0 21 4 12 53 366 31 1 2451910
|
||||
| 2,001 2001 001 01 1 21 1 01 01 001 01 2 2451911
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM FMWW FMDDD FMDD FMD FMJ')
|
||||
FROM TIMESTAMP_TBL;
|
||||
@ -941,6 +956,7 @@ SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM
|
||||
| 1,997 1997 997 97 7 20 1 2 6 41 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 2 6 41 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 2 6 41 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 2 6 41 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 2 6 23 161 10 3 2450610
|
||||
| 1,997 1997 997 97 7 20 1 2 6 41 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 2 6 42 11 3 2450491
|
||||
@ -972,7 +988,7 @@ SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM
|
||||
| 2,000 2000 000 00 0 21 1 1 1 1 1 7 2451545
|
||||
| 2,000 2000 000 00 0 21 4 12 53 366 31 1 2451910
|
||||
| 2,001 2001 001 01 1 21 1 1 1 1 1 2 2451911
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
|
||||
FROM TIMESTAMP_TBL;
|
||||
@ -1011,6 +1027,7 @@ SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
|
||||
| 05 05 17 32 01 63121
|
||||
| 05 05 17 32 01 63121
|
||||
| 05 05 17 32 01 63121
|
||||
| 02 02 14 32 01 52321
|
||||
| 06 06 18 32 01 66721
|
||||
| 05 05 17 32 01 63121
|
||||
| 05 05 17 32 01 63121
|
||||
@ -1042,7 +1059,7 @@ SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
|
||||
| 05 05 17 32 01 63121
|
||||
| 05 05 17 32 01 63121
|
||||
| 05 05 17 32 01 63121
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS to_char_6, to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""')
|
||||
FROM TIMESTAMP_TBL;
|
||||
@ -1081,6 +1098,7 @@ SELECT '' AS to_char_6, to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between qu
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 02:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 06:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
@ -1112,7 +1130,7 @@ SELECT '' AS to_char_6, to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between qu
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
|
||||
FROM TIMESTAMP_TBL;
|
||||
@ -1151,6 +1169,7 @@ SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
|
||||
| 17--text--32--text--01
|
||||
| 17--text--32--text--01
|
||||
| 17--text--32--text--01
|
||||
| 14--text--32--text--01
|
||||
| 18--text--32--text--01
|
||||
| 17--text--32--text--01
|
||||
| 17--text--32--text--01
|
||||
@ -1182,7 +1201,7 @@ SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
|
||||
| 17--text--32--text--01
|
||||
| 17--text--32--text--01
|
||||
| 17--text--32--text--01
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth')
|
||||
FROM TIMESTAMP_TBL;
|
||||
@ -1221,6 +1240,7 @@ SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth')
|
||||
| 1997TH 1997th 2450490th
|
||||
| 1997TH 1997th 2450490th
|
||||
| 1997TH 1997th 2450490th
|
||||
| 1997TH 1997th 2450490th
|
||||
| 1997TH 1997th 2450610th
|
||||
| 1997TH 1997th 2450490th
|
||||
| 1997TH 1997th 2450491st
|
||||
@ -1252,7 +1272,7 @@ SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth')
|
||||
| 2000TH 2000th 2451545th
|
||||
| 2000TH 2000th 2451910th
|
||||
| 2001ST 2001st 2451911th
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
|
||||
SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. HH:MI:SS p.m. HH:MI:SS pm')
|
||||
@ -1292,6 +1312,7 @@ SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. H
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 02:32:01 P.M. 02:32:01 p.m. 02:32:01 pm
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 06:32:01 P.M. 06:32:01 p.m. 06:32:01 pm
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
@ -1323,7 +1344,7 @@ SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. H
|
||||
| 2000 A.D. 2000 a.d. 2000 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
| 2000 A.D. 2000 a.d. 2000 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
| 2001 A.D. 2001 a.d. 2001 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
(64 rows)
|
||||
(65 rows)
|
||||
|
||||
-- TO_TIMESTAMP()
|
||||
SELECT '' AS to_timestamp_1, to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS');
|
||||
|
@ -97,6 +97,25 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('97FEB10 5:32:01PM UTC');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('97/02/10 17:32:01 UTC');
|
||||
reset datestyle;
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997.041 17:32:01 UTC');
|
||||
-- timestamps at different timezones
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 America/New_York');
|
||||
SELECT '19970210 173201' AT TIME ZONE 'America/New_York';
|
||||
timezone
|
||||
--------------------------
|
||||
Mon Feb 10 20:32:01 1997
|
||||
(1 row)
|
||||
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/New_York');
|
||||
SELECT '19970710 173201' AT TIME ZONE 'America/New_York';
|
||||
timezone
|
||||
--------------------------
|
||||
Thu Jul 10 20:32:01 1997
|
||||
(1 row)
|
||||
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/Does_not_exist');
|
||||
ERROR: time zone "America/Does_not_exist" not recognized
|
||||
SELECT '19970710 173201' AT TIME ZONE 'America/Does_not_exist';
|
||||
ERROR: time zone "America/Does_not_exist" not recognized
|
||||
-- Check date conversion and date arithmetic
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 18:32:01 PDT');
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997');
|
||||
@ -172,6 +191,8 @@ SELECT '' AS "64", d1 FROM TIMESTAMPTZ_TBL;
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 14:32:01 1997 PST
|
||||
| Thu Jul 10 14:32:01 1997 PDT
|
||||
| Tue Jun 10 18:32:01 1997 PDT
|
||||
| Mon Feb 10 17:32:01 1997 PST
|
||||
| Tue Feb 11 17:32:01 1997 PST
|
||||
@ -203,7 +224,7 @@ SELECT '' AS "64", d1 FROM TIMESTAMPTZ_TBL;
|
||||
| Sat Jan 01 17:32:01 2000 PST
|
||||
| Sun Dec 31 17:32:01 2000 PST
|
||||
| Mon Jan 01 17:32:01 2001 PST
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
-- Demonstrate functions and operators
|
||||
SELECT '' AS "48", d1 FROM TIMESTAMPTZ_TBL
|
||||
@ -240,6 +261,8 @@ SELECT '' AS "48", d1 FROM TIMESTAMPTZ_TBL
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 14:32:01 1997 PST
|
||||
| Thu Jul 10 14:32:01 1997 PDT
|
||||
| Tue Jun 10 18:32:01 1997 PDT
|
||||
| Mon Feb 10 17:32:01 1997 PST
|
||||
| Tue Feb 11 17:32:01 1997 PST
|
||||
@ -258,7 +281,7 @@ SELECT '' AS "48", d1 FROM TIMESTAMPTZ_TBL
|
||||
| Sat Jan 01 17:32:01 2000 PST
|
||||
| Sun Dec 31 17:32:01 2000 PST
|
||||
| Mon Jan 01 17:32:01 2001 PST
|
||||
(48 rows)
|
||||
(50 rows)
|
||||
|
||||
SELECT '' AS "15", d1 FROM TIMESTAMPTZ_TBL
|
||||
WHERE d1 < timestamp with time zone '1997-01-02';
|
||||
@ -324,6 +347,8 @@ SELECT '' AS "63", d1 FROM TIMESTAMPTZ_TBL
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 14:32:01 1997 PST
|
||||
| Thu Jul 10 14:32:01 1997 PDT
|
||||
| Tue Jun 10 18:32:01 1997 PDT
|
||||
| Mon Feb 10 17:32:01 1997 PST
|
||||
| Tue Feb 11 17:32:01 1997 PST
|
||||
@ -355,7 +380,7 @@ SELECT '' AS "63", d1 FROM TIMESTAMPTZ_TBL
|
||||
| Sat Jan 01 17:32:01 2000 PST
|
||||
| Sun Dec 31 17:32:01 2000 PST
|
||||
| Mon Jan 01 17:32:01 2001 PST
|
||||
(63 rows)
|
||||
(65 rows)
|
||||
|
||||
SELECT '' AS "16", d1 FROM TIMESTAMPTZ_TBL
|
||||
WHERE d1 <= timestamp with time zone '1997-01-02';
|
||||
@ -414,6 +439,8 @@ SELECT '' AS "49", d1 FROM TIMESTAMPTZ_TBL
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 09:32:01 1997 PST
|
||||
| Mon Feb 10 14:32:01 1997 PST
|
||||
| Thu Jul 10 14:32:01 1997 PDT
|
||||
| Tue Jun 10 18:32:01 1997 PDT
|
||||
| Mon Feb 10 17:32:01 1997 PST
|
||||
| Tue Feb 11 17:32:01 1997 PST
|
||||
@ -432,7 +459,7 @@ SELECT '' AS "49", d1 FROM TIMESTAMPTZ_TBL
|
||||
| Sat Jan 01 17:32:01 2000 PST
|
||||
| Sun Dec 31 17:32:01 2000 PST
|
||||
| Mon Jan 01 17:32:01 2001 PST
|
||||
(49 rows)
|
||||
(51 rows)
|
||||
|
||||
SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
|
||||
FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
|
||||
@ -469,6 +496,8 @@ SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
|
||||
| @ 39 days 9 hours 32 mins 1 sec
|
||||
| @ 39 days 9 hours 32 mins 1 sec
|
||||
| @ 39 days 9 hours 32 mins 1 sec
|
||||
| @ 39 days 14 hours 32 mins 1 sec
|
||||
| @ 189 days 13 hours 32 mins 1 sec
|
||||
| @ 159 days 17 hours 32 mins 1 sec
|
||||
| @ 39 days 17 hours 32 mins 1 sec
|
||||
| @ 40 days 17 hours 32 mins 1 sec
|
||||
@ -492,7 +521,7 @@ SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
|
||||
| @ 1094 days 17 hours 32 mins 1 sec
|
||||
| @ 1459 days 17 hours 32 mins 1 sec
|
||||
| @ 1460 days 17 hours 32 mins 1 sec
|
||||
(54 rows)
|
||||
(56 rows)
|
||||
|
||||
SELECT '' AS date_trunc_week, date_trunc( 'week', timestamp with time zone '2004-02-29 15:44:17.71393' ) AS week_trunc;
|
||||
date_trunc_week | week_trunc
|
||||
@ -537,6 +566,8 @@ SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
|
||||
| @ 39 days 9 hours 32 mins 1 sec
|
||||
| @ 39 days 9 hours 32 mins 1 sec
|
||||
| @ 39 days 9 hours 32 mins 1 sec
|
||||
| @ 39 days 14 hours 32 mins 1 sec
|
||||
| @ 189 days 13 hours 32 mins 1 sec
|
||||
| @ 159 days 17 hours 32 mins 1 sec
|
||||
| @ 39 days 17 hours 32 mins 1 sec
|
||||
| @ 40 days 17 hours 32 mins 1 sec
|
||||
@ -560,7 +591,7 @@ SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
|
||||
| @ 1094 days 17 hours 32 mins 1 sec
|
||||
| @ 1459 days 17 hours 32 mins 1 sec
|
||||
| @ 1460 days 17 hours 32 mins 1 sec
|
||||
(54 rows)
|
||||
(56 rows)
|
||||
|
||||
SELECT '' AS "54", d1 as timestamptz,
|
||||
date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
|
||||
@ -600,6 +631,8 @@ SELECT '' AS "54", d1 as timestamptz,
|
||||
| Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1
|
||||
| Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1
|
||||
| Mon Feb 10 09:32:01 1997 PST | 1997 | 2 | 10 | 9 | 32 | 1
|
||||
| Mon Feb 10 14:32:01 1997 PST | 1997 | 2 | 10 | 14 | 32 | 1
|
||||
| Thu Jul 10 14:32:01 1997 PDT | 1997 | 7 | 10 | 14 | 32 | 1
|
||||
| Tue Jun 10 18:32:01 1997 PDT | 1997 | 6 | 10 | 18 | 32 | 1
|
||||
| Mon Feb 10 17:32:01 1997 PST | 1997 | 2 | 10 | 17 | 32 | 1
|
||||
| Tue Feb 11 17:32:01 1997 PST | 1997 | 2 | 11 | 17 | 32 | 1
|
||||
@ -623,7 +656,7 @@ SELECT '' AS "54", d1 as timestamptz,
|
||||
| Sat Jan 01 17:32:01 2000 PST | 2000 | 1 | 1 | 17 | 32 | 1
|
||||
| Sun Dec 31 17:32:01 2000 PST | 2000 | 12 | 31 | 17 | 32 | 1
|
||||
| Mon Jan 01 17:32:01 2001 PST | 2001 | 1 | 1 | 17 | 32 | 1
|
||||
(54 rows)
|
||||
(56 rows)
|
||||
|
||||
SELECT '' AS "54", d1 as timestamptz,
|
||||
date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
|
||||
@ -662,6 +695,8 @@ SELECT '' AS "54", d1 as timestamptz,
|
||||
| Mon Feb 10 09:32:01 1997 PST | 1 | 1000 | 1000000
|
||||
| Mon Feb 10 09:32:01 1997 PST | 1 | 1000 | 1000000
|
||||
| Mon Feb 10 09:32:01 1997 PST | 1 | 1000 | 1000000
|
||||
| Mon Feb 10 14:32:01 1997 PST | 1 | 1000 | 1000000
|
||||
| Thu Jul 10 14:32:01 1997 PDT | 3 | 1000 | 1000000
|
||||
| Tue Jun 10 18:32:01 1997 PDT | 2 | 1000 | 1000000
|
||||
| Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
|
||||
| Tue Feb 11 17:32:01 1997 PST | 1 | 1000 | 1000000
|
||||
@ -685,7 +720,7 @@ SELECT '' AS "54", d1 as timestamptz,
|
||||
| Sat Jan 01 17:32:01 2000 PST | 1 | 1000 | 1000000
|
||||
| Sun Dec 31 17:32:01 2000 PST | 4 | 1000 | 1000000
|
||||
| Mon Jan 01 17:32:01 2001 PST | 1 | 1000 | 1000000
|
||||
(54 rows)
|
||||
(56 rows)
|
||||
|
||||
-- TO_CHAR()
|
||||
SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon')
|
||||
@ -725,6 +760,8 @@ SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM M
|
||||
| MONDAY Monday monday MON Mon mon FEBRUARY February february II FEB Feb feb
|
||||
| MONDAY Monday monday MON Mon mon FEBRUARY February february II FEB Feb feb
|
||||
| MONDAY Monday monday MON Mon mon FEBRUARY February february II FEB Feb feb
|
||||
| MONDAY Monday monday MON Mon mon FEBRUARY February february II FEB Feb feb
|
||||
| THURSDAY Thursday thursday THU Thu thu JULY July july VII JUL Jul jul
|
||||
| TUESDAY Tuesday tuesday TUE Tue tue JUNE June june VI JUN Jun jun
|
||||
| MONDAY Monday monday MON Mon mon FEBRUARY February february II FEB Feb feb
|
||||
| TUESDAY Tuesday tuesday TUE Tue tue FEBRUARY February february II FEB Feb feb
|
||||
@ -756,7 +793,7 @@ SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM M
|
||||
| SATURDAY Saturday saturday SAT Sat sat JANUARY January january I JAN Jan jan
|
||||
| SUNDAY Sunday sunday SUN Sun sun DECEMBER December december XII DEC Dec dec
|
||||
| MONDAY Monday monday MON Mon mon JANUARY January january I JAN Jan jan
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
|
||||
SELECT '' AS to_char_2, to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM')
|
||||
@ -796,6 +833,8 @@ SELECT '' AS to_char_2, to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth F
|
||||
| MONDAY Monday monday FEBRUARY February february II
|
||||
| MONDAY Monday monday FEBRUARY February february II
|
||||
| MONDAY Monday monday FEBRUARY February february II
|
||||
| MONDAY Monday monday FEBRUARY February february II
|
||||
| THURSDAY Thursday thursday JULY July july VII
|
||||
| TUESDAY Tuesday tuesday JUNE June june VI
|
||||
| MONDAY Monday monday FEBRUARY February february II
|
||||
| TUESDAY Tuesday tuesday FEBRUARY February february II
|
||||
@ -827,7 +866,7 @@ SELECT '' AS to_char_2, to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth F
|
||||
| SATURDAY Saturday saturday JANUARY January january I
|
||||
| SUNDAY Sunday sunday DECEMBER December december XII
|
||||
| MONDAY Monday monday JANUARY January january I
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
SELECT '' AS to_char_3, to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J')
|
||||
FROM TIMESTAMPTZ_TBL;
|
||||
@ -866,6 +905,8 @@ SELECT '' AS to_char_3, to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J')
|
||||
| 1,997 1997 997 97 7 20 1 02 06 041 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 02 06 041 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 02 06 041 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 02 06 041 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 3 07 28 191 10 5 2450640
|
||||
| 1,997 1997 997 97 7 20 2 06 23 161 10 3 2450610
|
||||
| 1,997 1997 997 97 7 20 1 02 06 041 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 02 06 042 11 3 2450491
|
||||
@ -897,7 +938,7 @@ SELECT '' AS to_char_3, to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J')
|
||||
| 2,000 2000 000 00 0 21 1 01 01 001 01 7 2451545
|
||||
| 2,000 2000 000 00 0 21 4 12 53 366 31 1 2451910
|
||||
| 2,001 2001 001 01 1 21 1 01 01 001 01 2 2451911
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
|
||||
SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM FMWW FMDDD FMDD FMD FMJ')
|
||||
@ -937,6 +978,8 @@ SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM
|
||||
| 1,997 1997 997 97 7 20 1 2 6 41 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 2 6 41 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 2 6 41 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 2 6 41 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 3 7 28 191 10 5 2450640
|
||||
| 1,997 1997 997 97 7 20 2 6 23 161 10 3 2450610
|
||||
| 1,997 1997 997 97 7 20 1 2 6 41 10 2 2450490
|
||||
| 1,997 1997 997 97 7 20 1 2 6 42 11 3 2450491
|
||||
@ -968,7 +1011,7 @@ SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM
|
||||
| 2,000 2000 000 00 0 21 1 1 1 1 1 7 2451545
|
||||
| 2,000 2000 000 00 0 21 4 12 53 366 31 1 2451910
|
||||
| 2,001 2001 001 01 1 21 1 1 1 1 1 2 2451911
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
|
||||
SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
|
||||
@ -1008,6 +1051,8 @@ SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
|
||||
| 09 09 09 32 01 34321
|
||||
| 09 09 09 32 01 34321
|
||||
| 09 09 09 32 01 34321
|
||||
| 02 02 14 32 01 52321
|
||||
| 02 02 14 32 01 52321
|
||||
| 06 06 18 32 01 66721
|
||||
| 05 05 17 32 01 63121
|
||||
| 05 05 17 32 01 63121
|
||||
@ -1039,7 +1084,7 @@ SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
|
||||
| 05 05 17 32 01 63121
|
||||
| 05 05 17 32 01 63121
|
||||
| 05 05 17 32 01 63121
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
SELECT '' AS to_char_6, to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""')
|
||||
FROM TIMESTAMPTZ_TBL;
|
||||
@ -1078,6 +1123,8 @@ SELECT '' AS to_char_6, to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between qu
|
||||
| HH:MI:SS is 09:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 09:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 09:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 02:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 02:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 06:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
@ -1109,7 +1156,7 @@ SELECT '' AS to_char_6, to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between qu
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
| HH:MI:SS is 05:32:01 "text between quote marks"
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
|
||||
SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
|
||||
@ -1149,6 +1196,8 @@ SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
|
||||
| 09--text--32--text--01
|
||||
| 09--text--32--text--01
|
||||
| 09--text--32--text--01
|
||||
| 14--text--32--text--01
|
||||
| 14--text--32--text--01
|
||||
| 18--text--32--text--01
|
||||
| 17--text--32--text--01
|
||||
| 17--text--32--text--01
|
||||
@ -1180,7 +1229,7 @@ SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
|
||||
| 17--text--32--text--01
|
||||
| 17--text--32--text--01
|
||||
| 17--text--32--text--01
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth')
|
||||
FROM TIMESTAMPTZ_TBL;
|
||||
@ -1219,6 +1268,8 @@ SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth')
|
||||
| 1997TH 1997th 2450490th
|
||||
| 1997TH 1997th 2450490th
|
||||
| 1997TH 1997th 2450490th
|
||||
| 1997TH 1997th 2450490th
|
||||
| 1997TH 1997th 2450640th
|
||||
| 1997TH 1997th 2450610th
|
||||
| 1997TH 1997th 2450490th
|
||||
| 1997TH 1997th 2450491st
|
||||
@ -1250,7 +1301,7 @@ SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth')
|
||||
| 2000TH 2000th 2451545th
|
||||
| 2000TH 2000th 2451910th
|
||||
| 2001ST 2001st 2451911th
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
|
||||
SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. HH:MI:SS p.m. HH:MI:SS pm')
|
||||
@ -1290,6 +1341,8 @@ SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. H
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 09:32:01 A.M. 09:32:01 a.m. 09:32:01 am
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 09:32:01 A.M. 09:32:01 a.m. 09:32:01 am
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 09:32:01 A.M. 09:32:01 a.m. 09:32:01 am
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 02:32:01 P.M. 02:32:01 p.m. 02:32:01 pm
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 02:32:01 P.M. 02:32:01 p.m. 02:32:01 pm
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 06:32:01 P.M. 06:32:01 p.m. 06:32:01 pm
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
| 1997 A.D. 1997 a.d. 1997 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
@ -1321,7 +1374,7 @@ SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. H
|
||||
| 2000 A.D. 2000 a.d. 2000 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
| 2000 A.D. 2000 a.d. 2000 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
| 2001 A.D. 2001 a.d. 2001 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
SELECT '' AS to_char_10, to_char(d1, 'YYYY WW IYYY IYY IY I IW')
|
||||
FROM TIMESTAMPTZ_TBL;
|
||||
@ -1360,6 +1413,8 @@ SELECT '' AS to_char_10, to_char(d1, 'YYYY WW IYYY IYY IY I IW')
|
||||
| 1997 06 1997 997 97 7 07
|
||||
| 1997 06 1997 997 97 7 07
|
||||
| 1997 06 1997 997 97 7 07
|
||||
| 1997 06 1997 997 97 7 07
|
||||
| 1997 28 1997 997 97 7 28
|
||||
| 1997 23 1997 997 97 7 24
|
||||
| 1997 06 1997 997 97 7 07
|
||||
| 1997 06 1997 997 97 7 07
|
||||
@ -1391,7 +1446,7 @@ SELECT '' AS to_char_10, to_char(d1, 'YYYY WW IYYY IYY IY I IW')
|
||||
| 2000 01 1999 999 99 9 52
|
||||
| 2000 53 2000 000 00 0 52
|
||||
| 2001 01 2001 001 01 1 01
|
||||
(64 rows)
|
||||
(66 rows)
|
||||
|
||||
-- TO_TIMESTAMP()
|
||||
SELECT '' AS to_timestamp_1, to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS');
|
||||
|
@ -12,6 +12,11 @@ INSERT INTO TIMETZ_TBL VALUES ('12:00 PDT');
|
||||
INSERT INTO TIMETZ_TBL VALUES ('12:01 PDT');
|
||||
INSERT INTO TIMETZ_TBL VALUES ('23:59 PDT');
|
||||
INSERT INTO TIMETZ_TBL VALUES ('11:59:59.99 PM PDT');
|
||||
INSERT INTO TIMETZ_TBL VALUES ('2003-03-07 15:36:39 America/New_York');
|
||||
INSERT INTO TIMETZ_TBL VALUES ('2003-07-07 15:36:39 America/New_York');
|
||||
-- this should fail (the timezone offset is not known)
|
||||
INSERT INTO TIMETZ_TBL VALUES ('15:36:39 America/New_York');
|
||||
ERROR: invalid input syntax for type time with time zone: "15:36:39 America/New_York"
|
||||
SELECT f1 AS "Time TZ" FROM TIMETZ_TBL;
|
||||
Time TZ
|
||||
----------------
|
||||
@ -25,7 +30,9 @@ SELECT f1 AS "Time TZ" FROM TIMETZ_TBL;
|
||||
12:01:00-07
|
||||
23:59:00-07
|
||||
23:59:59.99-07
|
||||
(10 rows)
|
||||
15:36:39-05
|
||||
15:36:39-04
|
||||
(12 rows)
|
||||
|
||||
SELECT f1 AS "Three" FROM TIMETZ_TBL WHERE f1 < '05:06:07-07';
|
||||
Three
|
||||
@ -45,7 +52,9 @@ SELECT f1 AS "Seven" FROM TIMETZ_TBL WHERE f1 > '05:06:07-07';
|
||||
12:01:00-07
|
||||
23:59:00-07
|
||||
23:59:59.99-07
|
||||
(7 rows)
|
||||
15:36:39-05
|
||||
15:36:39-04
|
||||
(9 rows)
|
||||
|
||||
SELECT f1 AS "None" FROM TIMETZ_TBL WHERE f1 < '00:00-07';
|
||||
None
|
||||
@ -65,7 +74,9 @@ SELECT f1 AS "Ten" FROM TIMETZ_TBL WHERE f1 >= '00:00-07';
|
||||
12:01:00-07
|
||||
23:59:00-07
|
||||
23:59:59.99-07
|
||||
(10 rows)
|
||||
15:36:39-05
|
||||
15:36:39-04
|
||||
(12 rows)
|
||||
|
||||
--
|
||||
-- TIME simple math
|
||||
|
@ -14,6 +14,12 @@ INSERT INTO TIME_TBL VALUES ('12:01');
|
||||
INSERT INTO TIME_TBL VALUES ('23:59');
|
||||
INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM');
|
||||
|
||||
INSERT INTO TIME_TBL VALUES ('2003-03-07 15:36:39 America/New_York');
|
||||
INSERT INTO TIME_TBL VALUES ('2003-07-07 15:36:39 America/New_York');
|
||||
-- this should fail (the timezone offset is not known)
|
||||
INSERT INTO TIME_TBL VALUES ('15:36:39 America/New_York');
|
||||
|
||||
|
||||
SELECT f1 AS "Time" FROM TIME_TBL;
|
||||
|
||||
SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07';
|
||||
|
@ -86,6 +86,11 @@ INSERT INTO TIMESTAMP_TBL VALUES ('97/02/10 17:32:01 UTC');
|
||||
reset datestyle;
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('1997.041 17:32:01 UTC');
|
||||
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 America/New_York');
|
||||
-- this fails
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('19970710 173201 America/Does_not_exist');
|
||||
|
||||
|
||||
-- Check date conversion and date arithmetic
|
||||
INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 18:32:01 PDT');
|
||||
|
||||
|
@ -80,6 +80,14 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('97/02/10 17:32:01 UTC');
|
||||
reset datestyle;
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997.041 17:32:01 UTC');
|
||||
|
||||
-- timestamps at different timezones
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 America/New_York');
|
||||
SELECT '19970210 173201' AT TIME ZONE 'America/New_York';
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/New_York');
|
||||
SELECT '19970710 173201' AT TIME ZONE 'America/New_York';
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/Does_not_exist');
|
||||
SELECT '19970710 173201' AT TIME ZONE 'America/Does_not_exist';
|
||||
|
||||
-- Check date conversion and date arithmetic
|
||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 18:32:01 PDT');
|
||||
|
||||
|
@ -15,6 +15,11 @@ INSERT INTO TIMETZ_TBL VALUES ('12:01 PDT');
|
||||
INSERT INTO TIMETZ_TBL VALUES ('23:59 PDT');
|
||||
INSERT INTO TIMETZ_TBL VALUES ('11:59:59.99 PM PDT');
|
||||
|
||||
INSERT INTO TIMETZ_TBL VALUES ('2003-03-07 15:36:39 America/New_York');
|
||||
INSERT INTO TIMETZ_TBL VALUES ('2003-07-07 15:36:39 America/New_York');
|
||||
-- this should fail (the timezone offset is not known)
|
||||
INSERT INTO TIMETZ_TBL VALUES ('15:36:39 America/New_York');
|
||||
|
||||
SELECT f1 AS "Time TZ" FROM TIMETZ_TBL;
|
||||
|
||||
SELECT f1 AS "Three" FROM TIMETZ_TBL WHERE f1 < '05:06:07-07';
|
||||
|
Loading…
Reference in New Issue
Block a user