for the usage of full time zone names.
Joachim Wieland
-<!-- $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>
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">
<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>
<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>
</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>
-<!-- $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>
<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>
</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
</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>
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>
-<!-- $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>
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>
| 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
| 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
| 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
| 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
| 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
| 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
| 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
| 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
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
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'
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
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
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
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
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
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
| 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
| 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
| 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
| 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
| 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
| 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
| 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
| 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
| 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
| 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
| 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
| 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
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
-------------
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
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
12:01:00
23:59:00
23:59:59.99
-(8 rows)
+ 15:36:39
+ 15:36:39
+(10 rows)
--
-- TIME simple math
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');
| 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
| 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
| 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
| 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';
| 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
| 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';
| 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
| 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';
| @ 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
| @ 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
| @ 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
| @ 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,
| 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
| 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,
| 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
| 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')
| 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
| 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;
| 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
| 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;
| 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
| 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;
| 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
| 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;
| 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
| 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;
| 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"
| 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;
| 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
| 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;
| 1997TH 1997th 2450490th
| 1997TH 1997th 2450490th
| 1997TH 1997th 2450490th
+ | 1997TH 1997th 2450490th
| 1997TH 1997th 2450610th
| 1997TH 1997th 2450490th
| 1997TH 1997th 2450491st
| 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')
| 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
| 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');
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');
| 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
| 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
| 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
| 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';
| 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
| 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';
| 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
| 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';
| @ 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
| @ 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
| @ 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
| @ 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,
| 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
| 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,
| 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
| 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')
| 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
| 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')
| 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
| 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;
| 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
| 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')
| 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
| 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')
| 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
| 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;
| 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"
| 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')
| 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
| 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;
| 1997TH 1997th 2450490th
| 1997TH 1997th 2450490th
| 1997TH 1997th 2450490th
+ | 1997TH 1997th 2450490th
+ | 1997TH 1997th 2450640th
| 1997TH 1997th 2450610th
| 1997TH 1997th 2450490th
| 1997TH 1997th 2450491st
| 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')
| 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
| 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;
| 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
| 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');
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
----------------
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
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
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
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';
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');
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');
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';