dbTalk Databases Forums  

Re: forcing date ordering

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Re: forcing date ordering in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Michael Glaesemann
 
Posts: n/a

Default Re: forcing date ordering - 09-11-2004 , 01:31 AM







On Sep 6, 2004, at 10:21 PM, tab view wrote:

Quote:
SELECT DISTINCT to_char(datetimelogged,'dd/mm/yyyy') AS datelogged
FROM logins ORDER BY datelogged DESC;

I don't seem to get the column sorted in date order. How do I force
psql to use date order?
What is the data type of the datetimelogged column?

Michael Glaesemann
grzm myrealbox com


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings



Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: forcing date ordering - 09-11-2004 , 02:22 AM






"tab view" <tabview (AT) hotmail (DOT) com> writes:
Quote:
When I do the following piece of SQL
SELECT DISTINCT to_char(datetimelogged,'dd/mm/yyyy') AS datelogged FROM
logins ORDER BY datelogged DESC;

I don't seem to get the column sorted in date order.
I'd expect that to produce a textual sorting of the to_char strings.

Quote:
How do I force psql to use date order?
Sort by the underlying datetimelogged column, which I suppose is of
date or timestamp type ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.