Sorting dates

Started by Hershel Fischalmost 17 years ago4 messagesbugs
Jump to latest
#1Hershel Fisch
hershrev@syp2u4c.com

Hi, I realized that sorting date is done like text and not numeric (dates)
e.g. SELELCT * FROM database_name ORDER BY date ASC

Return order

3/02/09
4/19/09
4/2/09

Thanks,

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Hershel Fisch (#1)
Re: Sorting dates

On Friday 15 May 2009 01:07:11 Hershel Fisch wrote:

Hi, I realized that sorting date is done like text and not numeric (dates)
e.g. SELELCT * FROM database_name ORDER BY date ASC

Return order

3/02/09
4/19/09
4/2/09

Thanks,

This report would make a lot more sense if you posted your schema definition.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#2)
Re: Sorting dates

Peter Eisentraut <peter_e@gmx.net> writes:

On Friday 15 May 2009 01:07:11 Hershel Fisch wrote:

Hi, I realized that sorting date is done like text and not numeric (dates)
e.g. SELELCT * FROM database_name ORDER BY date ASC

Return order

3/02/09
4/19/09
4/2/09

This report would make a lot more sense if you posted your schema definition.

I'd bet a good deal that the "date" column isn't a datetime type at all,
but text or varchar.

regards, tom lane

#4Francisco Olarte
folarte@peoplecall.com
In reply to: Peter Eisentraut (#2)
Re: Sorting dates

On Friday 15 May 2009 09:16:33 Peter Eisentraut wrote:

On Friday 15 May 2009 01:07:11 Hershel Fisch wrote:

Hi, I realized that sorting date is done like text and not numeric
(dates) e.g. SELELCT * FROM database_name ORDER BY date ASC

....

This report would make a lot more sense if you posted your schema
definition.

And the used query, I've been unable to make a seleLct order meaningfully.

F.O.S.