Re: Order By Date Question - Mailing list pgsql-general

From A. Kretschmer
Subject Re: Order By Date Question
Date
Msg-id 20090908143200.GC13727@a-kretschmer.de
Whole thread Raw
In response to Order By Date Question  (BlackMage <dsd7872@uncw.edu>)
List pgsql-general
In response to BlackMage :
>
> I have a question about ordering by date. I have a table with two fields and
> some date
>
> Name(character varying)  |  Event_Date(timestamp with timezone)
> A                                  |    2009-09-10 5:30:00
> B                                  |    2009-09-10- 00:00:00
> C                                  |    2009-09-11 17:30:00
> D                                  |  2009-09-11  07:30:00
>
>
> I want to order by date and then by name, so I want the result A,B,C,D. The
> problem is when I do a 'SELECT * FROM table_name ORDER BY Event_Date, DESC',
> it includes the actual time (HH:MM:SS) so the order comes out B,A,D,C.

Cast it to DATE, for instance:

 ... order by Event_Date::date desc


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)

pgsql-general by date:

Previous
From: Bill Moran
Date:
Subject: Re: Order By Date Question
Next
From: Sam Mason
Date:
Subject: Re: Order By Date Question