pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedstill sorting and casting problems
3+ messages / 3 participants
[nested] [flat]
* still sorting and casting problems
@ 2002-09-12 10:01 juerg.rietmann@pup.ch
2002-09-12 13:54 ` Re: still sorting and casting problems Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-09-12 13:57 ` Re: still sorting and casting problems Jeff Eckermann <jeff_eckermann@yahoo.com>
0 siblings, 2 replies; 3+ messages in thread
From: juerg.rietmann@pup.ch @ 2002-09-12 10:01 UTC (permalink / raw)
To: pgsql-sql
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
Please help and thank's in advance ... jr
__________________________________________________
PFISTER + PARTNER, SYSTEM - ENGINEERING AG
Juerg Rietmann
Grundstrasse 22a
6343 Rotkreuz
Switzerland
internet : www.pup.ch
phone : +4141 790 4040
fax : +4141 790 2545
mobile : +4179 211 0315
__________________________________________________
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: still sorting and casting problems
2002-09-12 10:01 still sorting and casting problems juerg.rietmann@pup.ch
@ 2002-09-12 13:54 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
1 sibling, 0 replies; 3+ messages in thread
From: Stephan Szabo @ 2002-09-12 13:54 UTC (permalink / raw)
To: juerg.rietmann@pup.ch; +Cc: pgsql-sql
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: still sorting and casting problems
2002-09-12 10:01 still sorting and casting problems juerg.rietmann@pup.ch
@ 2002-09-12 13:57 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Eckermann @ 2002-09-12 13:57 UTC (permalink / raw)
To: juerg.rietmann@pup.ch; pgsql-sql
--- juerg.rietmann@pup.ch wrote:
> 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
>
> Please help and thank's in advance ... jr
>
You haven't shown the error message here, but I'm
guessing that there is no direct cast between char and
date available in PostgreSQL. Try casting first to
text, then to date.
__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-09-12 13:57 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-09-12 10:01 still sorting and casting problems juerg.rietmann@pup.ch
2002-09-12 13:54 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-09-12 13:57 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox