From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | "Andrey Y(dot) Mosienko" <feo(at)ttn(dot)ru> |
Cc: | Postgres <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Sort by foreign date column |
Date: | 2001-08-21 12:54:27 |
Message-ID: | Pine.BSF.4.21.0108210551590.4969-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 21 Aug 2001, Andrey Y. Mosienko wrote:
> Stephan Szabo wrote:
> >
> > On Tue, 21 Aug 2001, Andrey Y. Mosienko wrote:
> >
> > >
> > > I have table with date type column:
> > >
> > > chdate date;
> > >
> > > SELECT chdate from mytable;
> > >
> > > chdate
> > > 1999-01-02
> > >
> > > But in Russia we have the next date format: DD-MM-YYYY.
> > >
> > > When I do coversion to char in SELECT:
> > > TO_CHAR(chdate,'DD-MM-YYYY') everything is ok, but sort by this column
> > > executes as sort for char type.
> > >
> > > How can I display my native date format and do right sorting by this column?
> >
> > Wouldn't
> > select to_char(chdate, 'DD-MM-YYYY') from mytable order by chdate;
> > work?
>
> Works. But sorting performs as for CHAR TYPE!
What version are you using? For me it orders by date.
sszabo=> create table datetest (d date);
CREATE
sszabo=> insert into datetest values ('12/11/2001');
INSERT 798850 1
sszabo=> insert into datetest values ('11/12/2001');
INSERT 798851 1
sszabo=> select * from datetest order by d;
d
------------
2001-11-12
2001-12-11
(2 rows)
sszabo=> select TO_CHAR(d, 'DD-MM-YYYY') from datetest order by d asc;
to_char
------------
12-11-2001
11-12-2001
(2 rows)
which appears to me to be date ordered not char ordered.
From | Date | Subject | |
---|---|---|---|
Next Message | Robert J. Sanford, Jr. | 2001-08-21 13:41:15 | RE: clustering and/or failover? |
Previous Message | newsreader | 2001-08-21 12:50:19 | Re: Re: is this possible? it should be! |