Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0B8C0475E24 for ; Thu, 12 Sep 2002 09:54:30 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 92F0D475D84 for ; Thu, 12 Sep 2002 09:54:25 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 72179D600; Thu, 12 Sep 2002 06:54:29 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 63C1C5C02; Thu, 12 Sep 2002 06:54:29 -0700 (PDT) Date: Thu, 12 Sep 2002 06:54:29 -0700 (PDT) From: Stephan Szabo To: Cc: Subject: Re: still sorting and casting problems In-Reply-To: Message-ID: <20020912065101.T45340-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/99 X-Sequence-Number: 9376 On Thu, 12 Sep 2002 juerg.rietmann@pup.ch wrote: > > Hello there > > Unfortunately, I can't change the fieldtype that easy because other > applications use the date as char(10) field as well. > > I need to sort the query by the log_date desc (log_date is char(10)). I > tried the following without success : > > select id, log_date from userlog order by cast (log_date as date) desc > > select id, log_date from userlog order by date(log_date) desc What do you get when trying this last query (something of the sort works for me in 7.3beta). It's possibly that you might need to use date(log_date::text) desc, but without the error it's hard to say.