Re: Order By Date Question

Поиск
Список
Период
Сортировка
Искать
От
Sam Mason
Тема
Re: Order By Date Question
Дата
Msg-id
20090908143247.GH5407@samason.me.uk
Ответ на
Список
Дерево обсуждения
Order By Date Question BlackMage <dsd7872@uncw.edu>
Re: Order By Date Question Adrian Klaver <aklaver@comcast.net>
Re: Order By Date Question Bill Moran <wmoran@potentialtech.com>
Re: Order By Date Question "A. Kretschmer" <andreas.kretschmer@schollglas.com>
Re: Order By Date Question Sam Mason <sam@samason.me.uk>
Re: Order By Date Question David Fetter <david@fetter.org>
On Tue, Sep 08, 2009 at 06:29:28AM -0700, BlackMage wrote:
> 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.
> 
> So what I am asking is how do I order only by the date? YYYY-MM-DD?

Casting to a date first is probably easiest, date_trunc would also work;
so one of:

  ORDER BY Event_Date::DATE, Name;
or
  ORDER BY date_trunc('day',Event_Date), Name;

-- 
  Sam  http://samason.me.uk/
В списке pgsql-general по дате отправления
От: A. Kretschmer
Дата:
Сообщение: Re: Order By Date Question
От: Adrian Klaver
Дата:
Сообщение: Re: Order By Date Question
FAQ