Re: need help with a number conversion

From: Alton Chinn <alton_chinn_at_ci.sf.ca.us>
Date: 11 Dec 2001 12:43:38 -0800
Message-ID: <f5dc5348.0112111243.47952583_at_posting.google.com>


hap_at_mikomi.org (Adam Hapworth) wrote in message news:<a6cb04db.0112110709.47542b8c_at_posting.google.com>...
> I am having a hard time trying to make this work.
>
> I have a number 1-7 for each day of the week in a database. I want to
> turn that into the 'day' format so 1 = 'sunday' and so on. I have
> tried a number of different ways but none of them work. I need this
> to do the next_day() function in oracle 8
>
> to_date(2,'day')
> ORA-01846: not a valid day of week
>
> to_char(2,'day')
> ORA-01481: invalid number format model
>
>
> any ideas will help

It sounds like the DECODE function is your best bet, as in:

SELECT DECODE(MYFIELD, 1, 'SUNDAY', 2, 'MONDAY', 3, 'TUESDAY', 4, 'WEDNESDAY', 5, 'THURSDAY', 6, 'FRIDAY', 7, 'SATURDAY', NULL) FROM MYTABLE; Alton Received on Tue Dec 11 2001 - 21:43:38 CET

Original text of this message