Re: Dates in inserts - Mailing list pgsql-general

From Nigel J. Andrews
Subject Re: Dates in inserts
Date
Msg-id Pine.LNX.4.21.0304011408280.2573-100000@ponder.fairway2k.co.uk
Whole thread Raw
In response to Dates in inserts  ("Michal Kalanski" <kalanskim@zetokatowice.pl>)
Responses Re: Dates in inserts  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Tue, 1 Apr 2003, Michal Kalanski wrote:

> Hello
>
> I have a table:
>
> CREATE TABLE public.dates (
> date timestamp
> )
>
> From psql I run following inserts:
>
> insert into dates values('13.01.03');
> insert into dates values('01.13.03');
>
> and I run select:
>
> select * from dates order by date;
>
> result:
>
>         date
> ---------------------
>  2003-01-13 00:00:00
>  2003-01-13 00:00:00
> (2 rows)
>
> Why postgresql inserts the same dates ?

Probably becuase there is no 13th month so 01.13.03 can only be interpreted as
the 13th of January. Whereas your settings are probably such that 13.01.03 is
interpreted correctly as the 13th of January.

Well, it's that or the 01.13.03 is correctly interpreted and the 13.01.03 can
only be interpreted as the 13th as there is no 13th month.

Find out which it is by doing:

SELECT '02.01.03'::date

and checking your DATE STYLE setting. I'm not sure without looking what the
variable is that controls the interpretation of input but DATE STYLE is
probably a good point to start looking from.

Interestingly, doing the above select on my 7.3 doesn't show the time portion,
presumably you're using something older.


>
> Thanks a lot,
> Michal

--
Nigel J. Andrews


pgsql-general by date:

Previous
From: "Michal Kalanski"
Date:
Subject: Re: Dates in inserts
Next
From: "Nigel J. Andrews"
Date:
Subject: dropping a table with dependencies