Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Problem with date conversion
bthomas_at_eises.equipement.gouv.fr (bthomas_at_eises.equipement.gouv.fr) wrote:
>
>Hello.
>
>I want to calc the month when I know the year (YYYY) and the week (WW)
>.
>If I try the query :
> SELECT TO_CHAR(TO_DATE('199701', 'YYYYWW'), 'MM')
> FROM dual;
>I got the error 'ORA-1820, format code cannot appear in date input for
>mat'
>
>Can you help me, please ?
>
>And it's better if you can send a copy by mail...
>
>Thank you.
>
SELECT TO_CHAR(TO_DATE('1997'||to_char(7*[1]), 'YYYYDDD'),'MM')
FROM dual;
Where '[1]' is the week number from above. This is simpler then the alternatives if you want a simple SQL statement rather than functions, etc. if your week value is determined with your need or non-need for offset.
-- \\/// (0-0) +----oOO----(_)-----------+ | K. E. Fein | | Database Analyst | | kfein_at_primenet.com | +------------------oOO----+Received on Mon Aug 11 1997 - 00:00:00 CDT