Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unexpected result calc in dates

Mburgos.arDec 28 2007 — edited Dec 28 2007
Hi everybody.

I'm confused about the results in a query.

I'm using decode to calculate the value of "COND" column, knowing today is "Friday"

SELECT TO_CHAR (SYSDATE, 'Day') COND FROM DUAL

But when I'm decoding this sentence in a query,

SELECT DECODE (TO_CHAR (SYSDATE, 'Day'), 'Friday', 'Today', 'Rest of week') COND FROM DUAL

I expected to get "Today" as the result, but what I obtain is "Rest of week"

First I thought in an error, but if I use a sustitution variable instead,

SELECT DECODE (:DD, 'Friday', 'Today', 'Rest of week') COND FROM DUAL

the result is the correct ("Today")

What am I doing wrong?

Thanks a lot
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 25 2008
Added on Dec 28 2007
3 comments
274 views