--
-- DATETIME
--
-- 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 'today' = (timestamp 'yesterday' + interval '1 day')) as "True";
 True 
------
 t
(1 row)

SELECT (timestamp 'today' = (timestamp 'tomorrow' - interval '1 day')) as "True";
 True 
------
 t
(1 row)

SELECT (timestamp 'tomorrow' = (timestamp 'yesterday' + interval '2 days')) as "True";
 True 
------
 t
(1 row)

SELECT (timestamp 'current' = 'now') as "True";
 True 
------
 t
(1 row)

SELECT (timestamp 'now' - 'current') AS "ZeroSecs";
 ZeroSecs 
----------
 @ 0
(1 row)

SET DateStyle = 'Postgres,NonEuropean';
SELECT timestamp(date '1994-01-01', time '11:00') AS "Jan_01_1994_11am";
       Jan_01_1994_11am       
------------------------------
 Sat Jan 01 11:00:00 1994 PST
(1 row)

SELECT timestamp(date '1994-01-01', time '10:00') AS "Jan_01_1994_10am";
       Jan_01_1994_10am       
------------------------------
 Sat Jan 01 10:00:00 1994 PST
(1 row)

SELECT timestamp(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_8am";
       Jan_01_1994_8am        
------------------------------
 Sat Jan 01 08:00:00 1994 PST
(1 row)

CREATE TABLE TIMESTAMP_TBL ( d1 timestamp);
INSERT INTO TIMESTAMP_TBL VALUES ('current');
INSERT INTO TIMESTAMP_TBL VALUES ('today');
INSERT INTO TIMESTAMP_TBL VALUES ('yesterday');
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow');
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow EST');
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow zulu');
SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'today';
 one 
-----
   1
(1 row)

SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'tomorrow';
 one 
-----
   1
(1 row)

SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'yesterday';
 one 
-----
   1
(1 row)

SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'today' + interval '1 day';
 one 
-----
   1
(1 row)

SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'today' - interval '1 day';
 one 
-----
   1
(1 row)

SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'now';
 one 
-----
   1
(1 row)

DELETE FROM TIMESTAMP_TBL;
-- verify uniform transaction time within transaction block
INSERT INTO TIMESTAMP_TBL VALUES ('current');
BEGIN;
INSERT INTO TIMESTAMP_TBL VALUES ('now');
SELECT count(*) AS two FROM TIMESTAMP_TBL WHERE d1 = timestamp 'now';
 two 
-----
   2
(1 row)

END;
DELETE FROM TIMESTAMP_TBL;
-- Special values
INSERT INTO TIMESTAMP_TBL VALUES ('invalid');
INSERT INTO TIMESTAMP_TBL VALUES ('-infinity');
INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
-- Postgres v6.0 standard output format
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('Invalid Abstime');
INSERT INTO TIMESTAMP_TBL VALUES ('Undefined Abstime');
-- Variations on Postgres v6.1 standard output format
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.000001 1997 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.4 1997 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.5 1997 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.6 1997 PST');
-- ISO 8601 format
INSERT INTO TIMESTAMP_TBL VALUES ('1997-01-02');
INSERT INTO TIMESTAMP_TBL VALUES ('1997-01-02 03:04:05');
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01-08');
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01-0800');
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 -08:00');
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 -0800');
INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 17:32:01 -07:00');
-- POSIX format
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 08:14:01 GMT+8');
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 13:14:02 GMT-1');
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 12:14:03 GMT -2');
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 03:14:04 EST+3');
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 02:14:05 EST +2:00');
-- Variations for acceptable input formats
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997 -0800');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 5:32PM 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('1997/02/10 17:32:01-0800');
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('02-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 PST');
INSERT INTO TIMESTAMP_TBL VALUES ('97FEB10 5:32:01PM UTC');
INSERT INTO TIMESTAMP_TBL VALUES ('97/02/10 17:32:01 UTC');
INSERT INTO TIMESTAMP_TBL VALUES ('97.041 17:32:01 UTC');
-- 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');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 11 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 12 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 13 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 14 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 15 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0097 BC');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0097');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0597');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1097');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1697');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1797');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1897');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 2097');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1996');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1996');
INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1996');
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1996');
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1996');
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1997');
ERROR:  Bad timestamp external representation 'Feb 29 17:32:01 1997'
INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1997');
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1999');
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2000');
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 2000');
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2001');
-- Currently unsupported syntax and ranges
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 -0097');
ERROR:  Bad timestamp external representation 'Feb 16 17:32:01 -0097'
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
ERROR:  Timestamp out of range 'Feb 16 17:32:01 5097 BC'
SELECT '' AS "66", d1 FROM TIMESTAMP_TBL; 
 66 |               d1                
----+---------------------------------
    | invalid
    | -infinity
    | infinity
    | epoch
    | Mon Feb 10 17:32:01 1997 PST
    | invalid
    | invalid
    | Mon Feb 10 17:32:01.00 1997 PST
    | Mon Feb 10 17:32:02.00 1997 PST
    | Mon Feb 10 17:32:01.40 1997 PST
    | Mon Feb 10 17:32:01.50 1997 PST
    | Mon Feb 10 17:32:01.60 1997 PST
    | Thu Jan 02 00:00:00 1997 PST
    | Thu Jan 02 03:04:05 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Tue Jun 10 17:32:01 1997 PDT
    | Wed Mar 15 08:14:01 2000 PST
    | Wed Mar 15 04:14:02 2000 PST
    | Wed Mar 15 02:14:03 2000 PST
    | Wed Mar 15 03:14:04 2000 PST
    | Wed Mar 15 01:14:05 2000 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:00 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Tue Jun 10 18:32:01 1997 PDT
    | Mon Feb 10 17:32:01 1997 PST
    | Tue Feb 11 17:32:01 1997 PST
    | Wed Feb 12 17:32:01 1997 PST
    | Thu Feb 13 17:32:01 1997 PST
    | Fri Feb 14 17:32:01 1997 PST
    | Sat Feb 15 17:32:01 1997 PST
    | Sun Feb 16 17:32:01 1997 PST
    | Tue Feb 16 17:32 0097 BC
    | Sat Feb 16 17:32:01 0097
    | Thu Feb 16 17:32:01 0597
    | Tue Feb 16 17:32:01 1097
    | Sat Feb 16 17:32:01 1697
    | Thu Feb 16 17:32:01 1797
    | Tue Feb 16 17:32:01 1897
    | Sun Feb 16 17:32:01 1997 PST
    | Sat Feb 16 17:32:01 2097
    | Wed Feb 28 17:32:01 1996 PST
    | Thu Feb 29 17:32:01 1996 PST
    | Fri Mar 01 17:32:01 1996 PST
    | Mon Dec 30 17:32:01 1996 PST
    | Tue Dec 31 17:32:01 1996 PST
    | Wed Jan 01 17:32:01 1997 PST
    | Fri Feb 28 17:32:01 1997 PST
    | Sat Mar 01 17:32:01 1997 PST
    | Tue Dec 30 17:32:01 1997 PST
    | Wed Dec 31 17:32:01 1997 PST
    | Fri Dec 31 17:32:01 1999 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
(66 rows)

-- Demonstrate functions and operators
SELECT '' AS "47", d1 FROM TIMESTAMP_TBL
   WHERE d1 > timestamp '1997-01-02' and d1 != timestamp 'current';
 47 |               d1                
----+---------------------------------
    | infinity
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01.00 1997 PST
    | Mon Feb 10 17:32:02.00 1997 PST
    | Mon Feb 10 17:32:01.40 1997 PST
    | Mon Feb 10 17:32:01.50 1997 PST
    | Mon Feb 10 17:32:01.60 1997 PST
    | Thu Jan 02 03:04:05 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Tue Jun 10 17:32:01 1997 PDT
    | Wed Mar 15 08:14:01 2000 PST
    | Wed Mar 15 04:14:02 2000 PST
    | Wed Mar 15 02:14:03 2000 PST
    | Wed Mar 15 03:14:04 2000 PST
    | Wed Mar 15 01:14:05 2000 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:00 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Tue Jun 10 18:32:01 1997 PDT
    | Mon Feb 10 17:32:01 1997 PST
    | Tue Feb 11 17:32:01 1997 PST
    | Wed Feb 12 17:32:01 1997 PST
    | Thu Feb 13 17:32:01 1997 PST
    | Fri Feb 14 17:32:01 1997 PST
    | Sat Feb 15 17:32:01 1997 PST
    | Sun Feb 16 17:32:01 1997 PST
    | Sun Feb 16 17:32:01 1997 PST
    | Sat Feb 16 17:32:01 2097
    | Fri Feb 28 17:32:01 1997 PST
    | Sat Mar 01 17:32:01 1997 PST
    | Tue Dec 30 17:32:01 1997 PST
    | Wed Dec 31 17:32:01 1997 PST
    | Fri Dec 31 17:32:01 1999 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
(47 rows)

SELECT '' AS "15", d1 FROM TIMESTAMP_TBL
   WHERE d1 < timestamp '1997-01-02' and d1 != timestamp 'current';
 15 |              d1              
----+------------------------------
    | -infinity
    | epoch
    | Tue Feb 16 17:32 0097 BC
    | Sat Feb 16 17:32:01 0097
    | Thu Feb 16 17:32:01 0597
    | Tue Feb 16 17:32:01 1097
    | Sat Feb 16 17:32:01 1697
    | Thu Feb 16 17:32:01 1797
    | Tue Feb 16 17:32:01 1897
    | Wed Feb 28 17:32:01 1996 PST
    | Thu Feb 29 17:32:01 1996 PST
    | Fri Mar 01 17:32:01 1996 PST
    | Mon Dec 30 17:32:01 1996 PST
    | Tue Dec 31 17:32:01 1996 PST
    | Wed Jan 01 17:32:01 1997 PST
(15 rows)

SELECT '' AS one, d1 FROM TIMESTAMP_TBL
   WHERE d1 = timestamp '1997-01-02' and d1 != timestamp 'current';
 one |              d1              
-----+------------------------------
     | Thu Jan 02 00:00:00 1997 PST
(1 row)

SELECT '' AS "62", d1 FROM TIMESTAMP_TBL
   WHERE d1 != timestamp '1997-01-02' and d1 != timestamp 'current';
 62 |               d1                
----+---------------------------------
    | -infinity
    | infinity
    | epoch
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01.00 1997 PST
    | Mon Feb 10 17:32:02.00 1997 PST
    | Mon Feb 10 17:32:01.40 1997 PST
    | Mon Feb 10 17:32:01.50 1997 PST
    | Mon Feb 10 17:32:01.60 1997 PST
    | Thu Jan 02 03:04:05 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Tue Jun 10 17:32:01 1997 PDT
    | Wed Mar 15 08:14:01 2000 PST
    | Wed Mar 15 04:14:02 2000 PST
    | Wed Mar 15 02:14:03 2000 PST
    | Wed Mar 15 03:14:04 2000 PST
    | Wed Mar 15 01:14:05 2000 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:00 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Tue Jun 10 18:32:01 1997 PDT
    | Mon Feb 10 17:32:01 1997 PST
    | Tue Feb 11 17:32:01 1997 PST
    | Wed Feb 12 17:32:01 1997 PST
    | Thu Feb 13 17:32:01 1997 PST
    | Fri Feb 14 17:32:01 1997 PST
    | Sat Feb 15 17:32:01 1997 PST
    | Sun Feb 16 17:32:01 1997 PST
    | Tue Feb 16 17:32 0097 BC
    | Sat Feb 16 17:32:01 0097
    | Thu Feb 16 17:32:01 0597
    | Tue Feb 16 17:32:01 1097
    | Sat Feb 16 17:32:01 1697
    | Thu Feb 16 17:32:01 1797
    | Tue Feb 16 17:32:01 1897
    | Sun Feb 16 17:32:01 1997 PST
    | Sat Feb 16 17:32:01 2097
    | Wed Feb 28 17:32:01 1996 PST
    | Thu Feb 29 17:32:01 1996 PST
    | Fri Mar 01 17:32:01 1996 PST
    | Mon Dec 30 17:32:01 1996 PST
    | Tue Dec 31 17:32:01 1996 PST
    | Wed Jan 01 17:32:01 1997 PST
    | Fri Feb 28 17:32:01 1997 PST
    | Sat Mar 01 17:32:01 1997 PST
    | Tue Dec 30 17:32:01 1997 PST
    | Wed Dec 31 17:32:01 1997 PST
    | Fri Dec 31 17:32:01 1999 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
(62 rows)

SELECT '' AS "16", d1 FROM TIMESTAMP_TBL
   WHERE d1 <= timestamp '1997-01-02' and d1 != timestamp 'current';
 16 |              d1              
----+------------------------------
    | -infinity
    | epoch
    | Thu Jan 02 00:00:00 1997 PST
    | Tue Feb 16 17:32 0097 BC
    | Sat Feb 16 17:32:01 0097
    | Thu Feb 16 17:32:01 0597
    | Tue Feb 16 17:32:01 1097
    | Sat Feb 16 17:32:01 1697
    | Thu Feb 16 17:32:01 1797
    | Tue Feb 16 17:32:01 1897
    | Wed Feb 28 17:32:01 1996 PST
    | Thu Feb 29 17:32:01 1996 PST
    | Fri Mar 01 17:32:01 1996 PST
    | Mon Dec 30 17:32:01 1996 PST
    | Tue Dec 31 17:32:01 1996 PST
    | Wed Jan 01 17:32:01 1997 PST
(16 rows)

SELECT '' AS "48", d1 FROM TIMESTAMP_TBL
   WHERE d1 >= timestamp '1997-01-02' and d1 != timestamp 'current';
 48 |               d1                
----+---------------------------------
    | infinity
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01.00 1997 PST
    | Mon Feb 10 17:32:02.00 1997 PST
    | Mon Feb 10 17:32:01.40 1997 PST
    | Mon Feb 10 17:32:01.50 1997 PST
    | Mon Feb 10 17:32:01.60 1997 PST
    | Thu Jan 02 00:00:00 1997 PST
    | Thu Jan 02 03:04:05 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Tue Jun 10 17:32:01 1997 PDT
    | Wed Mar 15 08:14:01 2000 PST
    | Wed Mar 15 04:14:02 2000 PST
    | Wed Mar 15 02:14:03 2000 PST
    | Wed Mar 15 03:14:04 2000 PST
    | Wed Mar 15 01:14:05 2000 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:00 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 17:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Mon Feb 10 09:32:01 1997 PST
    | Tue Jun 10 18:32:01 1997 PDT
    | Mon Feb 10 17:32:01 1997 PST
    | Tue Feb 11 17:32:01 1997 PST
    | Wed Feb 12 17:32:01 1997 PST
    | Thu Feb 13 17:32:01 1997 PST
    | Fri Feb 14 17:32:01 1997 PST
    | Sat Feb 15 17:32:01 1997 PST
    | Sun Feb 16 17:32:01 1997 PST
    | Sun Feb 16 17:32:01 1997 PST
    | Sat Feb 16 17:32:01 2097
    | Fri Feb 28 17:32:01 1997 PST
    | Sat Mar 01 17:32:01 1997 PST
    | Tue Dec 30 17:32:01 1997 PST
    | Wed Dec 31 17:32:01 1997 PST
    | Fri Dec 31 17:32:01 1999 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)

SELECT '' AS "66", d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL;
 66 |            one_year             
----+---------------------------------
    | invalid
    | -infinity
    | infinity
    | Thu Dec 31 16:00:00 1970 PST
    | Tue Feb 10 17:32:01 1998 PST
    | invalid
    | invalid
    | Tue Feb 10 17:32:01.00 1998 PST
    | Tue Feb 10 17:32:02.00 1998 PST
    | Tue Feb 10 17:32:01.40 1998 PST
    | Tue Feb 10 17:32:01.50 1998 PST
    | Tue Feb 10 17:32:01.60 1998 PST
    | Fri Jan 02 00:00:00 1998 PST
    | Fri Jan 02 03:04:05 1998 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Wed Jun 10 17:32:01 1998 PDT
    | Thu Mar 15 08:14:01 2001 PST
    | Thu Mar 15 04:14:02 2001 PST
    | Thu Mar 15 02:14:03 2001 PST
    | Thu Mar 15 03:14:04 2001 PST
    | Thu Mar 15 01:14:05 2001 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Tue Feb 10 17:32:00 1998 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Tue Feb 10 17:32:01 1998 PST
    | Tue Feb 10 09:32:01 1998 PST
    | Tue Feb 10 09:32:01 1998 PST
    | Tue Feb 10 09:32:01 1998 PST
    | Wed Jun 10 18:32:01 1998 PDT
    | Tue Feb 10 17:32:01 1998 PST
    | Wed Feb 11 17:32:01 1998 PST
    | Thu Feb 12 17:32:01 1998 PST
    | Fri Feb 13 17:32:01 1998 PST
    | Sat Feb 14 17:32:01 1998 PST
    | Sun Feb 15 17:32:01 1998 PST
    | Mon Feb 16 17:32:01 1998 PST
    | Thu Feb 16 17:32 0096 BC
    | Sun Feb 16 17:32:01 0098
    | Fri Feb 16 17:32:01 0598
    | Wed Feb 16 17:32:01 1098
    | Sun Feb 16 17:32:01 1698
    | Fri Feb 16 17:32:01 1798
    | Wed Feb 16 17:32:01 1898
    | Mon Feb 16 17:32:01 1998 PST
    | Sun Feb 16 17:32:01 2098
    | Fri Feb 28 17:32:01 1997 PST
    | Fri Feb 28 17:32:01 1997 PST
    | Sat Mar 01 17:32:01 1997 PST
    | Tue Dec 30 17:32:01 1997 PST
    | Wed Dec 31 17:32:01 1997 PST
    | Thu Jan 01 17:32:01 1998 PST
    | Sat Feb 28 17:32:01 1998 PST
    | Sun Mar 01 17:32:01 1998 PST
    | Wed Dec 30 17:32:01 1998 PST
    | Thu Dec 31 17:32:01 1998 PST
    | Sun Dec 31 17:32:01 2000 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
(66 rows)

SELECT '' AS "66", d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL;
 66 |            one_year             
----+---------------------------------
    | invalid
    | -infinity
    | infinity
    | Tue Dec 31 16:00:00 1968 PST
    | Sat Feb 10 17:32:01 1996 PST
    | invalid
    | invalid
    | Sat Feb 10 17:32:01.00 1996 PST
    | Sat Feb 10 17:32:02.00 1996 PST
    | Sat Feb 10 17:32:01.40 1996 PST
    | Sat Feb 10 17:32:01.50 1996 PST
    | Sat Feb 10 17:32:01.60 1996 PST
    | Tue Jan 02 00:00:00 1996 PST
    | Tue Jan 02 03:04:05 1996 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Mon Jun 10 17:32:01 1996 PDT
    | Mon Mar 15 08:14:01 1999 PST
    | Mon Mar 15 04:14:02 1999 PST
    | Mon Mar 15 02:14:03 1999 PST
    | Mon Mar 15 03:14:04 1999 PST
    | Mon Mar 15 01:14:05 1999 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Sat Feb 10 17:32:00 1996 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Sat Feb 10 17:32:01 1996 PST
    | Sat Feb 10 09:32:01 1996 PST
    | Sat Feb 10 09:32:01 1996 PST
    | Sat Feb 10 09:32:01 1996 PST
    | Mon Jun 10 18:32:01 1996 PDT
    | Sat Feb 10 17:32:01 1996 PST
    | Sun Feb 11 17:32:01 1996 PST
    | Mon Feb 12 17:32:01 1996 PST
    | Tue Feb 13 17:32:01 1996 PST
    | Wed Feb 14 17:32:01 1996 PST
    | Thu Feb 15 17:32:01 1996 PST
    | Fri Feb 16 17:32:01 1996 PST
    | Mon Feb 16 17:32 0098 BC
    | Thu Feb 16 17:32:01 0096
    | Tue Feb 16 17:32:01 0596
    | Sun Feb 16 17:32:01 1096
    | Thu Feb 16 17:32:01 1696
    | Tue Feb 16 17:32:01 1796
    | Sun Feb 16 17:32:01 1896
    | Fri Feb 16 17:32:01 1996 PST
    | Thu Feb 16 17:32:01 2096
    | Tue Feb 28 17:32:01 1995 PST
    | Tue Feb 28 17:32:01 1995 PST
    | Wed Mar 01 17:32:01 1995 PST
    | Sat Dec 30 17:32:01 1995 PST
    | Sun Dec 31 17:32:01 1995 PST
    | Mon Jan 01 17:32:01 1996 PST
    | Wed Feb 28 17:32:01 1996 PST
    | Fri Mar 01 17:32:01 1996 PST
    | Mon Dec 30 17:32:01 1996 PST
    | Tue Dec 31 17:32:01 1996 PST
    | Thu Dec 31 17:32:01 1998 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
(66 rows)

SELECT '' AS "53", d1 - timestamp '1997-01-02' AS diff
   FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
 53 |                  diff                  
----+----------------------------------------
    | @ 9863 days 8 hours ago
    | @ 39 days 17 hours 32 mins 1 sec
    | @ 39 days 17 hours 32 mins 1.00 secs
    | @ 39 days 17 hours 32 mins 2.00 secs
    | @ 39 days 17 hours 32 mins 1.40 secs
    | @ 39 days 17 hours 32 mins 1.50 secs
    | @ 39 days 17 hours 32 mins 1.60 secs
    | @ 0
    | @ 3 hours 4 mins 5 secs
    | @ 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 17 hours 32 mins 1 sec
    | @ 159 days 16 hours 32 mins 1 sec
    | @ 1168 days 8 hours 14 mins 1 sec
    | @ 1168 days 4 hours 14 mins 2 secs
    | @ 1168 days 2 hours 14 mins 3 secs
    | @ 1168 days 3 hours 14 mins 4 secs
    | @ 1168 days 1 hour 14 mins 5 secs
    | @ 39 days 17 hours 32 mins 1 sec
    | @ 39 days 17 hours 32 mins 1 sec
    | @ 39 days 17 hours 32 mins
    | @ 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 17 hours 32 mins 1 sec
    | @ 39 days 17 hours 32 mins 1 sec
    | @ 39 days 9 hours 32 mins 1 sec
    | @ 39 days 9 hours 32 mins 1 sec
    | @ 39 days 9 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
    | @ 41 days 17 hours 32 mins 1 sec
    | @ 42 days 17 hours 32 mins 1 sec
    | @ 43 days 17 hours 32 mins 1 sec
    | @ 44 days 17 hours 32 mins 1 sec
    | @ 45 days 17 hours 32 mins 1 sec
    | @ 45 days 17 hours 32 mins 1 sec
    | @ 308 days 6 hours 27 mins 59 secs ago
    | @ 307 days 6 hours 27 mins 59 secs ago
    | @ 306 days 6 hours 27 mins 59 secs ago
    | @ 2 days 6 hours 27 mins 59 secs ago
    | @ 1 day 6 hours 27 mins 59 secs ago
    | @ 6 hours 27 mins 59 secs ago
    | @ 57 days 17 hours 32 mins 1 sec
    | @ 58 days 17 hours 32 mins 1 sec
    | @ 362 days 17 hours 32 mins 1 sec
    | @ 363 days 17 hours 32 mins 1 sec
    | @ 1093 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
(53 rows)

-- Test casting within a BETWEEN qualifier
SELECT '' AS "53", d1 - timestamp '1997-01-02' AS diff
  FROM TIMESTAMP_TBL
  WHERE d1 BETWEEN timestamp '1902-01-01' AND timestamp '2038-01-01';
 53 |                  diff                  
----+----------------------------------------
    | @ 9863 days 8 hours ago
    | @ 39 days 17 hours 32 mins 1 sec
    | @ 39 days 17 hours 32 mins 1.00 secs
    | @ 39 days 17 hours 32 mins 2.00 secs
    | @ 39 days 17 hours 32 mins 1.40 secs
    | @ 39 days 17 hours 32 mins 1.50 secs
    | @ 39 days 17 hours 32 mins 1.60 secs
    | @ 0
    | @ 3 hours 4 mins 5 secs
    | @ 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 17 hours 32 mins 1 sec
    | @ 159 days 16 hours 32 mins 1 sec
    | @ 1168 days 8 hours 14 mins 1 sec
    | @ 1168 days 4 hours 14 mins 2 secs
    | @ 1168 days 2 hours 14 mins 3 secs
    | @ 1168 days 3 hours 14 mins 4 secs
    | @ 1168 days 1 hour 14 mins 5 secs
    | @ 39 days 17 hours 32 mins 1 sec
    | @ 39 days 17 hours 32 mins 1 sec
    | @ 39 days 17 hours 32 mins
    | @ 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 17 hours 32 mins 1 sec
    | @ 39 days 17 hours 32 mins 1 sec
    | @ 39 days 9 hours 32 mins 1 sec
    | @ 39 days 9 hours 32 mins 1 sec
    | @ 39 days 9 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
    | @ 41 days 17 hours 32 mins 1 sec
    | @ 42 days 17 hours 32 mins 1 sec
    | @ 43 days 17 hours 32 mins 1 sec
    | @ 44 days 17 hours 32 mins 1 sec
    | @ 45 days 17 hours 32 mins 1 sec
    | @ 45 days 17 hours 32 mins 1 sec
    | @ 308 days 6 hours 27 mins 59 secs ago
    | @ 307 days 6 hours 27 mins 59 secs ago
    | @ 306 days 6 hours 27 mins 59 secs ago
    | @ 2 days 6 hours 27 mins 59 secs ago
    | @ 1 day 6 hours 27 mins 59 secs ago
    | @ 6 hours 27 mins 59 secs ago
    | @ 57 days 17 hours 32 mins 1 sec
    | @ 58 days 17 hours 32 mins 1 sec
    | @ 362 days 17 hours 32 mins 1 sec
    | @ 363 days 17 hours 32 mins 1 sec
    | @ 1093 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
(53 rows)

SELECT '' AS "53", date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
   date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
   date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
   FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
 53 | year | month | day | hour | minute |  second  
----+------+-------+-----+------+--------+----------
    | 1969 |    12 |  31 |   16 |      0 |        0
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 | 1.000001
    | 1997 |     2 |  10 |   17 |     32 | 1.999999
    | 1997 |     2 |  10 |   17 |     32 |      1.4
    | 1997 |     2 |  10 |   17 |     32 |      1.5
    | 1997 |     2 |  10 |   17 |     32 |      1.6
    | 1997 |     1 |   2 |    0 |      0 |        0
    | 1997 |     1 |   2 |    3 |      4 |        5
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     6 |  10 |   17 |     32 |        1
    | 2000 |     3 |  15 |    8 |     14 |        1
    | 2000 |     3 |  15 |    4 |     14 |        2
    | 2000 |     3 |  15 |    2 |     14 |        3
    | 2000 |     3 |  15 |    3 |     14 |        4
    | 2000 |     3 |  15 |    1 |     14 |        5
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 |        0
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  10 |    9 |     32 |        1
    | 1997 |     2 |  10 |    9 |     32 |        1
    | 1997 |     2 |  10 |    9 |     32 |        1
    | 1997 |     6 |  10 |   18 |     32 |        1
    | 1997 |     2 |  10 |   17 |     32 |        1
    | 1997 |     2 |  11 |   17 |     32 |        1
    | 1997 |     2 |  12 |   17 |     32 |        1
    | 1997 |     2 |  13 |   17 |     32 |        1
    | 1997 |     2 |  14 |   17 |     32 |        1
    | 1997 |     2 |  15 |   17 |     32 |        1
    | 1997 |     2 |  16 |   17 |     32 |        1
    | 1997 |     2 |  16 |   17 |     32 |        1
    | 1996 |     2 |  28 |   17 |     32 |        1
    | 1996 |     2 |  29 |   17 |     32 |        1
    | 1996 |     3 |   1 |   17 |     32 |        1
    | 1996 |    12 |  30 |   17 |     32 |        1
    | 1996 |    12 |  31 |   17 |     32 |        1
    | 1997 |     1 |   1 |   17 |     32 |        1
    | 1997 |     2 |  28 |   17 |     32 |        1
    | 1997 |     3 |   1 |   17 |     32 |        1
    | 1997 |    12 |  30 |   17 |     32 |        1
    | 1997 |    12 |  31 |   17 |     32 |        1
    | 1999 |    12 |  31 |   17 |     32 |        1
    | 2000 |     1 |   1 |   17 |     32 |        1
    | 2000 |    12 |  31 |   17 |     32 |        1
    | 2001 |     1 |   1 |   17 |     32 |        1
(53 rows)

SELECT '' AS "53", date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
   date_part( 'usec', d1) AS usec
   FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
 53 | quarter |         msec         |       usec        
----+---------+----------------------+-------------------
    |       4 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 | 0.000999999999917733 | 0.999999999917733
    |       1 |              999.999 |            999999
    |       1 |                  400 |            400000
    |       1 |                  500 |            500000
    |       1 |                  600 |            600000
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       2 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       2 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       4 |                    0 |                 0
    |       4 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       1 |                    0 |                 0
    |       4 |                    0 |                 0
    |       4 |                    0 |                 0
    |       4 |                    0 |                 0
    |       1 |                    0 |                 0
    |       4 |                    0 |                 0
    |       1 |                    0 |                 0
(53 rows)

-- TO_CHAR()
--
SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon') 
   FROM TIMESTAMP_TBL;
 to_char_1 |                                         to_char                                          
-----------+------------------------------------------------------------------------------------------
           | 
           | 
           | 
           | THURSDAY  Thursday  thursday  THU Thu thu JANUARY   January   january   I    JAN Jan jan
           | 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
           | 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 JANUARY   January   january   I    JAN Jan jan
           | THURSDAY  Thursday  thursday  THU Thu thu JANUARY   January   january   I    JAN Jan jan
           | 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
           | WEDNESDAY Wednesday wednesday WED Wed wed MARCH     March     march     III  MAR Mar mar
           | WEDNESDAY Wednesday wednesday WED Wed wed MARCH     March     march     III  MAR Mar mar
           | WEDNESDAY Wednesday wednesday WED Wed wed MARCH     March     march     III  MAR Mar mar
           | WEDNESDAY Wednesday wednesday WED Wed wed MARCH     March     march     III  MAR Mar mar
           | WEDNESDAY Wednesday wednesday WED Wed wed MARCH     March     march     III  MAR Mar mar
           | 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
           | 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
           | 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
           | WEDNESDAY Wednesday wednesday WED Wed wed FEBRUARY  February  february  II   FEB Feb feb
           | THURSDAY  Thursday  thursday  THU Thu thu FEBRUARY  February  february  II   FEB Feb feb
           | FRIDAY    Friday    friday    FRI Fri fri FEBRUARY  February  february  II   FEB Feb feb
           | SATURDAY  Saturday  saturday  SAT Sat sat FEBRUARY  February  february  II   FEB Feb feb
           | SUNDAY    Sunday    sunday    SUN Sun sun 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 FEBRUARY  February  february  II   FEB Feb feb
           | THURSDAY  Thursday  thursday  THU Thu thu 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 FEBRUARY  February  february  II   FEB Feb feb
           | THURSDAY  Thursday  thursday  THU Thu thu FEBRUARY  February  february  II   FEB Feb feb
           | TUESDAY   Tuesday   tuesday   TUE Tue tue FEBRUARY  February  february  II   FEB Feb feb
           | SUNDAY    Sunday    sunday    SUN Sun sun FEBRUARY  February  february  II   FEB Feb feb
           | SATURDAY  Saturday  saturday  SAT Sat sat FEBRUARY  February  february  II   FEB Feb feb
           | WEDNESDAY Wednesday wednesday WED Wed wed FEBRUARY  February  february  II   FEB Feb feb
           | THURSDAY  Thursday  thursday  THU Thu thu FEBRUARY  February  february  II   FEB Feb feb
           | FRIDAY    Friday    friday    FRI Fri fri MARCH     March     march     III  MAR Mar mar
           | MONDAY    Monday    monday    MON Mon mon DECEMBER  December  december  XII  DEC Dec dec
           | TUESDAY   Tuesday   tuesday   TUE Tue tue DECEMBER  December  december  XII  DEC Dec dec
           | WEDNESDAY Wednesday wednesday WED Wed wed JANUARY   January   january   I    JAN Jan jan
           | FRIDAY    Friday    friday    FRI Fri fri FEBRUARY  February  february  II   FEB Feb feb
           | SATURDAY  Saturday  saturday  SAT Sat sat MARCH     March     march     III  MAR Mar mar
           | TUESDAY   Tuesday   tuesday   TUE Tue tue DECEMBER  December  december  XII  DEC Dec dec
           | WEDNESDAY Wednesday wednesday WED Wed wed DECEMBER  December  december  XII  DEC Dec dec
           | FRIDAY    Friday    friday    FRI Fri fri DECEMBER  December  december  XII  DEC Dec dec
           | 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
(66 rows)

	
SELECT '' AS to_char_2, to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM')
   FROM TIMESTAMP_TBL;	
 to_char_2 |                           to_char                            
-----------+--------------------------------------------------------------
           | 
           | 
           | 
           | THURSDAY Thursday thursday JANUARY January january I
           | 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
           | MONDAY Monday monday FEBRUARY February february II
           | MONDAY Monday monday FEBRUARY February february II
           | THURSDAY Thursday thursday JANUARY January january I
           | THURSDAY Thursday thursday JANUARY January january I
           | 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
           | WEDNESDAY Wednesday wednesday MARCH March march III
           | WEDNESDAY Wednesday wednesday MARCH March march III
           | WEDNESDAY Wednesday wednesday MARCH March march III
           | WEDNESDAY Wednesday wednesday MARCH March march III
           | WEDNESDAY Wednesday wednesday MARCH March march III
           | 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
           | 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
           | 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
           | WEDNESDAY Wednesday wednesday FEBRUARY February february II
           | THURSDAY Thursday thursday FEBRUARY February february II
           | FRIDAY Friday friday FEBRUARY February february II
           | SATURDAY Saturday saturday FEBRUARY February february II
           | SUNDAY Sunday sunday FEBRUARY February february II
           | TUESDAY Tuesday tuesday FEBRUARY February february II
           | SATURDAY Saturday saturday FEBRUARY February february II
           | THURSDAY Thursday thursday FEBRUARY February february II
           | TUESDAY Tuesday tuesday FEBRUARY February february II
           | SATURDAY Saturday saturday FEBRUARY February february II
           | THURSDAY Thursday thursday FEBRUARY February february II
           | TUESDAY Tuesday tuesday FEBRUARY February february II
           | SUNDAY Sunday sunday FEBRUARY February february II
           | SATURDAY Saturday saturday FEBRUARY February february II
           | WEDNESDAY Wednesday wednesday FEBRUARY February february II
           | THURSDAY Thursday thursday FEBRUARY February february II
           | FRIDAY Friday friday MARCH March march III
           | MONDAY Monday monday DECEMBER December december XII
           | TUESDAY Tuesday tuesday DECEMBER December december XII
           | WEDNESDAY Wednesday wednesday JANUARY January january I
           | FRIDAY Friday friday FEBRUARY February february II
           | SATURDAY Saturday saturday MARCH March march III
           | TUESDAY Tuesday tuesday DECEMBER December december XII
           | WEDNESDAY Wednesday wednesday DECEMBER December december XII
           | FRIDAY Friday friday DECEMBER December december XII
           | SATURDAY Saturday saturday JANUARY January january I
           | SUNDAY Sunday sunday DECEMBER December december XII
           | MONDAY Monday monday JANUARY January january I
(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 TIMESTAMP_TBL;
 to_char_3 |                        to_char                        
-----------+-------------------------------------------------------
           | 
           | 
           | 
           | 1,970 1970 970 70 0 20 1 01 00 001 01 5 2440588
           | 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 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 01 00 002 02 5 2450451
           | 1,997 1997 997 97 7 20 1 01 00 002 02 5 2450451
           | 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
           | 2,000 2000 000 00 0 21 1 03 11 075 15 4 2451619
           | 2,000 2000 000 00 0 21 1 03 11 075 15 4 2451619
           | 2,000 2000 000 00 0 21 1 03 11 075 15 4 2451619
           | 2,000 2000 000 00 0 21 1 03 11 075 15 4 2451619
           | 2,000 2000 000 00 0 21 1 03 11 075 15 4 2451619
           | 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 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 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
           | 1,997 1997 997 97 7 20 1 02 06 043 12 4 2450492
           | 1,997 1997 997 97 7 20 1 02 06 044 13 5 2450493
           | 1,997 1997 997 97 7 20 1 02 06 045 14 6 2450494
           | 1,997 1997 997 97 7 20 1 02 06 046 15 7 2450495
           | 1,997 1997 997 97 7 20 1 02 07 047 16 1 2450496
           | 0,097 BC 0097 BC 097 97 7 01 1 02 07 047 16 3 1686042
           | 0,097 0097 097 97 7 01 1 02 06 047 16 7 1756536
           | 0,597 0597 597 97 7 06 1 02 07 047 16 5 1939157
           | 1,097 1097 097 97 7 11 1 02 07 047 16 3 2121778
           | 1,697 1697 697 97 7 17 1 02 06 047 16 7 2340924
           | 1,797 1797 797 97 7 18 1 02 07 047 16 5 2377448
           | 1,897 1897 897 97 7 19 1 02 07 047 16 3 2413972
           | 1,997 1997 997 97 7 20 1 02 07 047 16 1 2450496
           | 2,097 2097 097 97 7 21 1 02 06 047 16 7 2487021
           | 1,996 1996 996 96 6 20 1 02 09 059 28 4 2450142
           | 1,996 1996 996 96 6 20 1 02 09 060 29 5 2450143
           | 1,996 1996 996 96 6 20 1 03 09 061 01 6 2450144
           | 1,996 1996 996 96 6 20 4 12 53 365 30 2 2450448
           | 1,996 1996 996 96 6 20 4 12 53 366 31 3 2450449
           | 1,997 1997 997 97 7 20 1 01 00 001 01 4 2450450
           | 1,997 1997 997 97 7 20 1 02 08 059 28 6 2450508
           | 1,997 1997 997 97 7 20 1 03 08 060 01 7 2450509
           | 1,997 1997 997 97 7 20 4 12 52 364 30 3 2450813
           | 1,997 1997 997 97 7 20 4 12 52 365 31 4 2450814
           | 1,999 1999 999 99 9 20 4 12 52 365 31 6 2451544
           | 2,000 2000 000 00 0 21 1 01 00 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
(66 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;	
 to_char_4 |                     to_char                     
-----------+-------------------------------------------------
           | 
           | 
           | 
           | 1,970 1970 970 70 0 20 1 1 0 1 1 5 2440588
           | 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 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 1 0 2 2 5 2450451
           | 1,997 1997 997 97 7 20 1 1 0 2 2 5 2450451
           | 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
           | 2,000 2000 000 00 0 21 1 3 11 75 15 4 2451619
           | 2,000 2000 000 00 0 21 1 3 11 75 15 4 2451619
           | 2,000 2000 000 00 0 21 1 3 11 75 15 4 2451619
           | 2,000 2000 000 00 0 21 1 3 11 75 15 4 2451619
           | 2,000 2000 000 00 0 21 1 3 11 75 15 4 2451619
           | 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 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 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
           | 1,997 1997 997 97 7 20 1 2 6 43 12 4 2450492
           | 1,997 1997 997 97 7 20 1 2 6 44 13 5 2450493
           | 1,997 1997 997 97 7 20 1 2 6 45 14 6 2450494
           | 1,997 1997 997 97 7 20 1 2 6 46 15 7 2450495
           | 1,997 1997 997 97 7 20 1 2 7 47 16 1 2450496
           | 0,097 BC 97 BC 097 97 7 1 1 2 7 47 16 3 1686042
           | 0,097 97 097 97 7 1 1 2 6 47 16 7 1756536
           | 0,597 597 597 97 7 6 1 2 7 47 16 5 1939157
           | 1,097 1097 097 97 7 11 1 2 7 47 16 3 2121778
           | 1,697 1697 697 97 7 17 1 2 6 47 16 7 2340924
           | 1,797 1797 797 97 7 18 1 2 7 47 16 5 2377448
           | 1,897 1897 897 97 7 19 1 2 7 47 16 3 2413972
           | 1,997 1997 997 97 7 20 1 2 7 47 16 1 2450496
           | 2,097 2097 097 97 7 21 1 2 6 47 16 7 2487021
           | 1,996 1996 996 96 6 20 1 2 9 59 28 4 2450142
           | 1,996 1996 996 96 6 20 1 2 9 60 29 5 2450143
           | 1,996 1996 996 96 6 20 1 3 9 61 1 6 2450144
           | 1,996 1996 996 96 6 20 4 12 53 365 30 2 2450448
           | 1,996 1996 996 96 6 20 4 12 53 366 31 3 2450449
           | 1,997 1997 997 97 7 20 1 1 0 1 1 4 2450450
           | 1,997 1997 997 97 7 20 1 2 8 59 28 6 2450508
           | 1,997 1997 997 97 7 20 1 3 8 60 1 7 2450509
           | 1,997 1997 997 97 7 20 4 12 52 364 30 3 2450813
           | 1,997 1997 997 97 7 20 4 12 52 365 31 4 2450814
           | 1,999 1999 999 99 9 20 4 12 52 365 31 6 2451544
           | 2,000 2000 000 00 0 21 1 1 0 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
(66 rows)

	
SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS') 
   FROM TIMESTAMP_TBL;
 to_char_5 |       to_char        
-----------+----------------------
           | 
           | 
           | 
           | 12 12 00 00 00 0
           | 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
           | 05 05 17 32 01 63121
           | 12 12 00 00 00 0
           | 03 03 03 04 05 11045
           | 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
           | 08 08 08 14 01 29641
           | 04 04 04 14 02 15242
           | 02 02 02 14 03 8043
           | 03 03 03 14 04 11644
           | 01 01 01 14 05 4445
           | 05 05 17 32 01 63121
           | 05 05 17 32 01 63121
           | 05 05 17 32 00 63120
           | 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
           | 09 09 09 32 01 34321
           | 09 09 09 32 01 34321
           | 09 09 09 32 01 34321
           | 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
           | 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
           | 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
           | 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
           | 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
           | 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
(66 rows)

SELECT '' AS to_char_6, to_char(d1, '"HH:MI:SS is" HH:MI:SS "\\"text bettween quote marks\\""') 
   FROM TIMESTAMP_TBL;		
 to_char_6 |                     to_char                      
-----------+--------------------------------------------------
           | 
           | 
           | 
           | HH:MI:SS is 12:00:00 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | 
           | 
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 12:00:00 "text bettween quote marks"
           | HH:MI:SS is 03:04:05 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 08:14:01 "text bettween quote marks"
           | HH:MI:SS is 04:14:02 "text bettween quote marks"
           | HH:MI:SS is 02:14:03 "text bettween quote marks"
           | HH:MI:SS is 03:14:04 "text bettween quote marks"
           | HH:MI:SS is 01:14:05 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:00 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 09:32:01 "text bettween quote marks"
           | HH:MI:SS is 09:32:01 "text bettween quote marks"
           | HH:MI:SS is 09:32:01 "text bettween quote marks"
           | HH:MI:SS is 06:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
           | HH:MI:SS is 05:32:01 "text bettween quote marks"
(66 rows)

		
SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
   FROM TIMESTAMP_TBL;		
 to_char_7 |        to_char         
-----------+------------------------
           | 
           | 
           | 
           | 00--text--00--text--00
           | 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
           | 17--text--32--text--01
           | 00--text--00--text--00
           | 03--text--04--text--05
           | 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
           | 08--text--14--text--01
           | 04--text--14--text--02
           | 02--text--14--text--03
           | 03--text--14--text--04
           | 01--text--14--text--05
           | 17--text--32--text--01
           | 17--text--32--text--01
           | 17--text--32--text--00
           | 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
           | 09--text--32--text--01
           | 09--text--32--text--01
           | 09--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
           | 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
           | 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
           | 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
           | 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
           | 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
(66 rows)

SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth') 
   FROM TIMESTAMP_TBL;
 to_char_8 |            to_char            
-----------+-------------------------------
           | 
           | 
           | 
           | 1970TH 1970th 2440588th
           | 1997TH 1997th 2450490th
           | 
           | 
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450451st
           | 1997TH 1997th 2450451st
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450610th
           | 2000TH 2000th 2451619th
           | 2000TH 2000th 2451619th
           | 2000TH 2000th 2451619th
           | 2000TH 2000th 2451619th
           | 2000TH 2000th 2451619th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450610th
           | 1997TH 1997th 2450490th
           | 1997TH 1997th 2450491st
           | 1997TH 1997th 2450492nd
           | 1997TH 1997th 2450493rd
           | 1997TH 1997th 2450494th
           | 1997TH 1997th 2450495th
           | 1997TH 1997th 2450496th
           | 0097TH BC 0097th BC 1686042nd
           | 0097TH 0097th 1756536th
           | 0597TH 0597th 1939157th
           | 1097TH 1097th 2121778th
           | 1697TH 1697th 2340924th
           | 1797TH 1797th 2377448th
           | 1897TH 1897th 2413972nd
           | 1997TH 1997th 2450496th
           | 2097TH 2097th 2487021st
           | 1996TH 1996th 2450142nd
           | 1996TH 1996th 2450143rd
           | 1996TH 1996th 2450144th
           | 1996TH 1996th 2450448th
           | 1996TH 1996th 2450449th
           | 1997TH 1997th 2450450th
           | 1997TH 1997th 2450508th
           | 1997TH 1997th 2450509th
           | 1997TH 1997th 2450813rd
           | 1997TH 1997th 2450814th
           | 1999TH 1999th 2451544th
           | 2000TH 2000th 2451545th
           | 2000TH 2000th 2451910th
           | 2001ST 2001st 2451911st
(66 rows)

-- TO_TIMESTAMP()
--
SELECT '' AS to_timestamp_1, to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS');
 to_timestamp_1 |       to_timestamp       
----------------+--------------------------
                | Sat Feb 16 08:14:30 0097
(1 row)

	
SELECT '' AS to_timestamp_2, to_timestamp('97/2/16 8:14:30', 'FMYYYY/FMMM/FMDD FMHH:FMMI:FMSS');
 to_timestamp_2 |       to_timestamp       
----------------+--------------------------
                | Sat Feb 16 08:14:30 0097
(1 row)

SELECT '' AS to_timestamp_3, to_timestamp('1985 January 12', 'YYYY FMMonth DD');
 to_timestamp_3 |         to_timestamp         
----------------+------------------------------
                | Sat Jan 12 00:00:00 1985 PST
(1 row)

SELECT '' AS to_timestamp_4, to_timestamp('My birthday-> Year: 1976, Month: May, Day: 16',
                    '"My birthday-> Year" YYYY, "Month:" FMMonth, "Day:" DD');
 to_timestamp_4 |         to_timestamp         
----------------+------------------------------
                | Sun May 16 00:00:00 1976 PDT
(1 row)

SELECT '' AS to_timestamp_5, to_timestamp('1,582nd VIII 21', 'Y,YYYth FMRM DD');
 to_timestamp_5 |       to_timestamp       
----------------+--------------------------
                | Sat Aug 21 00:00:00 1582
(1 row)

SELECT '' AS to_timestamp_6, to_timestamp('15 "text bettween quote marks" 98 54 45', 
                    'HH "\\text bettween quote marks\\"" YY MI SS');
 to_timestamp_6 |       to_timestamp       
----------------+--------------------------
                | Wed Jan 01 15:54:45 0098
(1 row)

    
SELECT '' AS to_timestamp_7, to_timestamp('05121445482000', 'MMDDHHMISSYYYY');    
 to_timestamp_7 |         to_timestamp         
----------------+------------------------------
                | Fri May 12 14:45:48 2000 PDT
(1 row)

SELECT '' AS to_timestamp_8, to_timestamp('2000January09Sunday', 'YYYYFMMonthDDFMDay');
 to_timestamp_8 |         to_timestamp         
----------------+------------------------------
                | Sun Jan 09 00:00:00 2000 PST
(1 row)

