Thread: 3 digit ISO dates

3 digit ISO dates

From
"Christopher Kings-Lynne"
Date:
Hi,

Are we going to address the fact that you can't enter 3 digit years without
a leading 0?

australia=# select '111-01-01'::date;
ERROR:  Bad date external representation '111-01-01'

australia=# select '0111-01-01'::date;   date
------------0111-01-01
(1 row)

I can't see any reason why we shouldn't allow it???

Chris



Re: 3 digit ISO dates

From
Andreas Joseph Krogh
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 15 September 2003 09:09, Christopher Kings-Lynne wrote:
> Hi,
>
> Are we going to address the fact that you can't enter 3 digit years without
> a leading 0?
>
> australia=# select '111-01-01'::date;
> ERROR:  Bad date external representation '111-01-01'
>
> australia=# select '0111-01-01'::date;
>     date
> ------------
>  0111-01-01
> (1 row)
>
> I can't see any reason why we shouldn't allow it???

Works here(7.4beta2):

andreak=# select '111-01-01'::date;   date
- ------------0111-01-01
(1 row)

andreak=# select version();                                                 version
- -----------------------------------------------------------------------------------------------------------PostgreSQL
7.4beta2on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.2  
(Mandrake Linux 9.1 3.2.2-3mdk)
(1 row)

- --
Andreas Joseph Krogh <andreak@officenet.no>
Managing Director, Senior Software Developer
OfficeNet AS

- - There are 10 kinds of people in the world, those that can do binary arithmetic and those that can't.

gpg public_key: http://dev.officenet.no/~andreak/public_key.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/ZW3mUopImDh2gfQRAlNIAKCF62WbRGJSP1QwM+qJzUjBiSM3gQCbBM4N
SmXAdFqCK+Wf6EVTw/W9buo=
=+Hrc
-----END PGP SIGNATURE-----


Re: 3 digit ISO dates

From
"Christopher Kings-Lynne"
Date:
> > I can't see any reason why we shouldn't allow it???
>
> Works here(7.4beta2):
>
> andreak=# select '111-01-01'::date;
>     date
> - ------------
>  0111-01-01
> (1 row)

Ooooh - that must have been a side effect of the 'only parse dates in set
format' changes...was it intended?

Chris



Re: 3 digit ISO dates

From
Tom Lane
Date:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> Ooooh - that must have been a side effect of the 'only parse dates in set
> format' changes...was it intended?

Yes, I thought so.  The relevant bit of the change is here:

!   /***
!    * Enough digits to be unequivocal year? Used to test for 4 digits or
!    * more, but we now test first for a three-digit doy so anything
!    * bigger than two digits had better be an explicit year.
!    * - thomas 1999-01-09
!    * Back to requiring a 4 digit year. We accept a two digit
!    * year farther down. - thomas 2000-03-28
!    ***/
!   else if (flen >= 4)   {
!       *tmask = DTK_M(YEAR);

--- 2408,2498 ----

!           case 0:
!               /*
!                * Nothing so far; make a decision about what we think the
!                * input is.  There used to be lots of heuristics here, but
!                * the consensus now is to be paranoid.  It *must* be either
!                * YYYY-MM-DD (with a more-than-two-digit year field), or the
!                * field order defined by DateOrder.
!                */
!               if (flen >= 3 || DateOrder == DATEORDER_YMD)
!               {
!                   *tmask = DTK_M(YEAR);

        regards, tom lane