*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.62 2002/01/12 04:38:27 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.63 2002/03/04 03:55:46 ishii Exp $
*
*-------------------------------------------------------------------------
*/
switch (val)
{
case DTK_MICROSEC:
- result = (fsec * 1000000);
+ result = (tm->tm_sec + fsec) * 1000000;
break;
case DTK_MILLISEC:
- result = (fsec * 1000);
+ result = (tm->tm_sec + fsec) * 1000;
break;
case DTK_SECOND:
break;
case DTK_MICROSEC:
- result = (fsec * 1000000);
+ result = (tm->tm_sec + fsec) * 1000000;
break;
case DTK_MILLISEC:
- result = (fsec * 1000);
+ result = (tm->tm_sec + fsec) * 1000;
break;
case DTK_SECOND:
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';
- 54 | timestamp | quarter | msec | usec
-----+-----------------------------+---------+------+--------
- | Thu Jan 01 00:00:00 1970 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:02 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01.40 1997 | 1 | 400 | 400000
- | Mon Feb 10 17:32:01.50 1997 | 1 | 500 | 500000
- | Mon Feb 10 17:32:01.60 1997 | 1 | 600 | 600000
- | Thu Jan 02 00:00:00 1997 | 1 | 0 | 0
- | Thu Jan 02 03:04:05 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Tue Jun 10 17:32:01 1997 | 2 | 0 | 0
- | Sat Sep 22 18:19:20 2001 | 3 | 0 | 0
- | Wed Mar 15 08:14:01 2000 | 1 | 0 | 0
- | Wed Mar 15 13:14:02 2000 | 1 | 0 | 0
- | Wed Mar 15 12:14:03 2000 | 1 | 0 | 0
- | Wed Mar 15 03:14:04 2000 | 1 | 0 | 0
- | Wed Mar 15 02:14:05 2000 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:00 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Tue Jun 10 18:32:01 1997 | 2 | 0 | 0
- | Mon Feb 10 17:32:01 1997 | 1 | 0 | 0
- | Tue Feb 11 17:32:01 1997 | 1 | 0 | 0
- | Wed Feb 12 17:32:01 1997 | 1 | 0 | 0
- | Thu Feb 13 17:32:01 1997 | 1 | 0 | 0
- | Fri Feb 14 17:32:01 1997 | 1 | 0 | 0
- | Sat Feb 15 17:32:01 1997 | 1 | 0 | 0
- | Sun Feb 16 17:32:01 1997 | 1 | 0 | 0
- | Sun Feb 16 17:32:01 1997 | 1 | 0 | 0
- | Wed Feb 28 17:32:01 1996 | 1 | 0 | 0
- | Thu Feb 29 17:32:01 1996 | 1 | 0 | 0
- | Fri Mar 01 17:32:01 1996 | 1 | 0 | 0
- | Mon Dec 30 17:32:01 1996 | 4 | 0 | 0
- | Tue Dec 31 17:32:01 1996 | 4 | 0 | 0
- | Wed Jan 01 17:32:01 1997 | 1 | 0 | 0
- | Fri Feb 28 17:32:01 1997 | 1 | 0 | 0
- | Sat Mar 01 17:32:01 1997 | 1 | 0 | 0
- | Tue Dec 30 17:32:01 1997 | 4 | 0 | 0
- | Wed Dec 31 17:32:01 1997 | 4 | 0 | 0
- | Fri Dec 31 17:32:01 1999 | 4 | 0 | 0
- | Sat Jan 01 17:32:01 2000 | 1 | 0 | 0
- | Sun Dec 31 17:32:01 2000 | 4 | 0 | 0
- | Mon Jan 01 17:32:01 2001 | 1 | 0 | 0
+ 54 | timestamp | quarter | msec | usec
+----+-----------------------------+---------+-------+----------
+ | Thu Jan 01 00:00:00 1970 | 1 | 0 | 0
+ | 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:02 1997 | 1 | 2000 | 2000000
+ | Mon Feb 10 17:32:01.40 1997 | 1 | 1400 | 1400000
+ | Mon Feb 10 17:32:01.50 1997 | 1 | 1500 | 1500000
+ | Mon Feb 10 17:32:01.60 1997 | 1 | 1600 | 1600000
+ | Thu Jan 02 00:00:00 1997 | 1 | 0 | 0
+ | Thu Jan 02 03:04:05 1997 | 1 | 5000 | 5000000
+ | 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 17:32:01 1997 | 1 | 1000 | 1000000
+ | Tue Jun 10 17:32:01 1997 | 2 | 1000 | 1000000
+ | Sat Sep 22 18:19:20 2001 | 3 | 20000 | 20000000
+ | Wed Mar 15 08:14:01 2000 | 1 | 1000 | 1000000
+ | Wed Mar 15 13:14:02 2000 | 1 | 2000 | 2000000
+ | Wed Mar 15 12:14:03 2000 | 1 | 3000 | 3000000
+ | Wed Mar 15 03:14:04 2000 | 1 | 4000 | 4000000
+ | Wed Mar 15 02:14:05 2000 | 1 | 5000 | 5000000
+ | 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:00 1997 | 1 | 0 | 0
+ | 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 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 17:32:01 1997 | 1 | 1000 | 1000000
+ | Mon Feb 10 17: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
+ | Wed Feb 12 17:32:01 1997 | 1 | 1000 | 1000000
+ | Thu Feb 13 17:32:01 1997 | 1 | 1000 | 1000000
+ | Fri Feb 14 17:32:01 1997 | 1 | 1000 | 1000000
+ | Sat Feb 15 17:32:01 1997 | 1 | 1000 | 1000000
+ | Sun Feb 16 17:32:01 1997 | 1 | 1000 | 1000000
+ | Sun Feb 16 17:32:01 1997 | 1 | 1000 | 1000000
+ | Wed Feb 28 17:32:01 1996 | 1 | 1000 | 1000000
+ | Thu Feb 29 17:32:01 1996 | 1 | 1000 | 1000000
+ | Fri Mar 01 17:32:01 1996 | 1 | 1000 | 1000000
+ | Mon Dec 30 17:32:01 1996 | 4 | 1000 | 1000000
+ | Tue Dec 31 17:32:01 1996 | 4 | 1000 | 1000000
+ | Wed Jan 01 17:32:01 1997 | 1 | 1000 | 1000000
+ | Fri Feb 28 17:32:01 1997 | 1 | 1000 | 1000000
+ | Sat Mar 01 17:32:01 1997 | 1 | 1000 | 1000000
+ | Tue Dec 30 17:32:01 1997 | 4 | 1000 | 1000000
+ | Wed Dec 31 17:32:01 1997 | 4 | 1000 | 1000000
+ | Fri Dec 31 17:32:01 1999 | 4 | 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)
-- TO_CHAR()
date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
date_part( 'usec', d1) AS usec
FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
- 54 | timestamptz | quarter | msec | usec
-----+---------------------------------+---------+------+--------
- | Wed Dec 31 16:00:00 1969 PST | 4 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:02 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01.40 1997 PST | 1 | 400 | 400000
- | Mon Feb 10 17:32:01.50 1997 PST | 1 | 500 | 500000
- | Mon Feb 10 17:32:01.60 1997 PST | 1 | 600 | 600000
- | Thu Jan 02 00:00:00 1997 PST | 1 | 0 | 0
- | Thu Jan 02 03:04:05 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Tue Jun 10 17:32:01 1997 PDT | 2 | 0 | 0
- | Sat Sep 22 18:19:20 2001 PDT | 3 | 0 | 0
- | Wed Mar 15 08:14:01 2000 PST | 1 | 0 | 0
- | Wed Mar 15 04:14:02 2000 PST | 1 | 0 | 0
- | Wed Mar 15 02:14:03 2000 PST | 1 | 0 | 0
- | Wed Mar 15 03:14:04 2000 PST | 1 | 0 | 0
- | Wed Mar 15 01:14:05 2000 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:00 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 09:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 09:32:01 1997 PST | 1 | 0 | 0
- | Mon Feb 10 09:32:01 1997 PST | 1 | 0 | 0
- | Tue Jun 10 18:32:01 1997 PDT | 2 | 0 | 0
- | Mon Feb 10 17:32:01 1997 PST | 1 | 0 | 0
- | Tue Feb 11 17:32:01 1997 PST | 1 | 0 | 0
- | Wed Feb 12 17:32:01 1997 PST | 1 | 0 | 0
- | Thu Feb 13 17:32:01 1997 PST | 1 | 0 | 0
- | Fri Feb 14 17:32:01 1997 PST | 1 | 0 | 0
- | Sat Feb 15 17:32:01 1997 PST | 1 | 0 | 0
- | Sun Feb 16 17:32:01 1997 PST | 1 | 0 | 0
- | Sun Feb 16 17:32:01 1997 PST | 1 | 0 | 0
- | Wed Feb 28 17:32:01 1996 PST | 1 | 0 | 0
- | Thu Feb 29 17:32:01 1996 PST | 1 | 0 | 0
- | Fri Mar 01 17:32:01 1996 PST | 1 | 0 | 0
- | Mon Dec 30 17:32:01 1996 PST | 4 | 0 | 0
- | Tue Dec 31 17:32:01 1996 PST | 4 | 0 | 0
- | Wed Jan 01 17:32:01 1997 PST | 1 | 0 | 0
- | Fri Feb 28 17:32:01 1997 PST | 1 | 0 | 0
- | Sat Mar 01 17:32:01 1997 PST | 1 | 0 | 0
- | Tue Dec 30 17:32:01 1997 PST | 4 | 0 | 0
- | Wed Dec 31 17:32:01 1997 PST | 4 | 0 | 0
- | Fri Dec 31 17:32:01 1999 PST | 4 | 0 | 0
- | Sat Jan 01 17:32:01 2000 PST | 1 | 0 | 0
- | Sun Dec 31 17:32:01 2000 PST | 4 | 0 | 0
- | Mon Jan 01 17:32:01 2001 PST | 1 | 0 | 0
+ 54 | timestamptz | quarter | msec | usec
+----+---------------------------------+---------+-------+----------
+ | Wed Dec 31 16:00:00 1969 PST | 4 | 0 | 0
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17:32:02 1997 PST | 1 | 2000 | 2000000
+ | Mon Feb 10 17:32:01.40 1997 PST | 1 | 1400 | 1400000
+ | Mon Feb 10 17:32:01.50 1997 PST | 1 | 1500 | 1500000
+ | Mon Feb 10 17:32:01.60 1997 PST | 1 | 1600 | 1600000
+ | Thu Jan 02 00:00:00 1997 PST | 1 | 0 | 0
+ | Thu Jan 02 03:04:05 1997 PST | 1 | 5000 | 5000000
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Tue Jun 10 17:32:01 1997 PDT | 2 | 1000 | 1000000
+ | Sat Sep 22 18:19:20 2001 PDT | 3 | 20000 | 20000000
+ | Wed Mar 15 08:14:01 2000 PST | 1 | 1000 | 1000000
+ | Wed Mar 15 04:14:02 2000 PST | 1 | 2000 | 2000000
+ | Wed Mar 15 02:14:03 2000 PST | 1 | 3000 | 3000000
+ | Wed Mar 15 03:14:04 2000 PST | 1 | 4000 | 4000000
+ | Wed Mar 15 01:14:05 2000 PST | 1 | 5000 | 5000000
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17:32:00 1997 PST | 1 | 0 | 0
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Mon Feb 10 17: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 09:32:01 1997 PST | 1 | 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
+ | Wed Feb 12 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Thu Feb 13 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Fri Feb 14 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Sat Feb 15 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Sun Feb 16 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Sun Feb 16 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Wed Feb 28 17:32:01 1996 PST | 1 | 1000 | 1000000
+ | Thu Feb 29 17:32:01 1996 PST | 1 | 1000 | 1000000
+ | Fri Mar 01 17:32:01 1996 PST | 1 | 1000 | 1000000
+ | Mon Dec 30 17:32:01 1996 PST | 4 | 1000 | 1000000
+ | Tue Dec 31 17:32:01 1996 PST | 4 | 1000 | 1000000
+ | Wed Jan 01 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Fri Feb 28 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Sat Mar 01 17:32:01 1997 PST | 1 | 1000 | 1000000
+ | Tue Dec 30 17:32:01 1997 PST | 4 | 1000 | 1000000
+ | Wed Dec 31 17:32:01 1997 PST | 4 | 1000 | 1000000
+ | Fri Dec 31 17:32:01 1999 PST | 4 | 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)
-- TO_CHAR()