1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-10 14:22:35 +03:00

> > I have no idea if this in Oracle or not. But it's something I

> > needed, and other people in the past asked about it too.
>
> It is in Oracle, but you aren't exactly on the spot.  It should be
>
> IYYY - 4 digits  ('2003')
> IYY  - 3 digits  ('003')
> IY   - 2 digits  ('03')
> I    - 1 digit   ('3')

Here is an updated patch that does that.

Kurt Roeckx
This commit is contained in:
Bruce Momjian
2003-12-25 03:36:24 +00:00
parent 03caf7649b
commit 1c757c49fa
6 changed files with 220 additions and 10 deletions

View File

@@ -1317,6 +1317,76 @@ SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. H
| 2001 A.D. 2001 a.d. 2001 ad 05:32:01 P.M. 05:32:01 p.m. 05:32:01 pm
(64 rows)
SELECT '' AS to_char_10, to_char(d1, 'YYYY WW IYYY IYY IY I IW')
FROM TIMESTAMPTZ_TBL;
to_char_10 | to_char
------------+--------------------------
|
|
| 1969 53 1970 970 70 0 01
| 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 06 1997 997 97 7 07
| 1997 06 1997 997 97 7 07
| 1997 01 1997 997 97 7 01
| 1997 01 1997 997 97 7 01
| 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 23 1997 997 97 7 24
| 2001 38 2001 001 01 1 38
| 2000 11 2000 000 00 0 11
| 2000 11 2000 000 00 0 11
| 2000 11 2000 000 00 0 11
| 2000 11 2000 000 00 0 11
| 2000 11 2000 000 00 0 11
| 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 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 06 1997 997 97 7 07
| 1997 06 1997 997 97 7 07
| 1997 06 1997 997 97 7 07
| 1997 23 1997 997 97 7 24
| 1997 06 1997 997 97 7 07
| 1997 06 1997 997 97 7 07
| 1997 07 1997 997 97 7 07
| 1997 07 1997 997 97 7 07
| 1997 07 1997 997 97 7 07
| 1997 07 1997 997 97 7 07
| 1997 07 1997 997 97 7 07
| 0097 07 0097 097 97 7 07
| 0097 07 0097 097 97 7 07
| 0597 07 0597 597 97 7 07
| 1097 07 1097 097 97 7 07
| 1697 07 1697 697 97 7 07
| 1797 07 1797 797 97 7 07
| 1897 07 1897 897 97 7 07
| 1997 07 1997 997 97 7 07
| 2097 07 2097 097 97 7 07
| 1996 09 1996 996 96 6 09
| 1996 09 1996 996 96 6 09
| 1996 09 1996 996 96 6 09
| 1996 53 1997 997 97 7 01
| 1996 53 1997 997 97 7 01
| 1997 01 1997 997 97 7 01
| 1997 09 1997 997 97 7 09
| 1997 09 1997 997 97 7 09
| 1997 52 1998 998 98 8 01
| 1997 53 1998 998 98 8 01
| 1999 53 1999 999 99 9 52
| 2000 01 1999 999 99 9 52
| 2000 53 2000 000 00 0 52
| 2001 01 2001 001 01 1 01
(64 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
@@ -1402,4 +1472,16 @@ SELECT '' AS to_timestamp_14, to_timestamp('995-1116', 'YYY-MMDD');
| Thu Nov 16 00:00:00 1995 PST
(1 row)
SELECT '' AS to_timestamp_15, to_timestamp('200401', 'IYYYIW');
to_timestamp_15 | to_timestamp
-----------------+------------------------------
| Mon Dec 29 00:00:00 2003 PST
(1 row)
SELECT '' AS to_timestamp_16, to_timestamp('200401', 'YYYYWW');
to_timestamp_16 | to_timestamp
-----------------+------------------------------
| Thu Jan 01 00:00:00 2004 PST
(1 row)
SET DateStyle TO DEFAULT;

View File

@@ -189,6 +189,9 @@ SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth')
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')
FROM TIMESTAMPTZ_TBL;
SELECT '' AS to_char_10, to_char(d1, 'YYYY WW IYYY IYY IY I IW')
FROM TIMESTAMPTZ_TBL;
-- TO_TIMESTAMP()
SELECT '' AS to_timestamp_1, to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS');
@@ -220,4 +223,9 @@ SELECT '' AS to_timestamp_13, to_timestamp('95-1116', 'YY-MMDD');
SELECT '' AS to_timestamp_14, to_timestamp('995-1116', 'YYY-MMDD');
SELECT '' AS to_timestamp_15, to_timestamp('200401', 'IYYYIW');
SELECT '' AS to_timestamp_16, to_timestamp('200401', 'YYYYWW');
SET DateStyle TO DEFAULT;