Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: strange behavior of decode?

Re: strange behavior of decode?

From: Mark D Powell <mark.powellNOmaSPAM_at_eds.com.invalid>
Date: 2000/08/11
Message-ID: <1f66bba0.27812ee8@usw-ex0102-015.remarq.com>#1/1

samuels_at_red.seas.upenn.edu (Maurice Samuels) wrote:
>can anyone explain to me why this does not work:
>
>select to_char(sysdate,'Day') from dual;
>output -> Friday
>
>select decode(to_char(sysdate,'Day'),'Friday',1,2) from dual;
>output -> 2
>
>why is the output not 1?
>
>if i do:
>select decode(to_char(sysdate,'Dy'),'Fri',1,2) from dual;
>output -> 1
>
>why does the decode work in this case but not the previous?
>any help would be much appreciated.
>-maurice
>samuels_at_seas.upenn.edu
>
>

The Day appears to always return 9 characters which would match the longest day of the week, wednesday. This is the same manner in which to_char returns the spelled out month.

  1* select decode(to_char(sysdate,'Day'),'Friday ',1,2) from dual
SQL> / DECODE(TO_CHAR(SYSDATE,'DAY'),'FRIDAY',1,2)


                                          1



Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free!
http://www.keen.com Received on Fri Aug 11 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US