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

Home -> Community -> Usenet -> c.d.o.server -> Re: Problem with date conversion

Re: Problem with date conversion

From: KE Fein <kfein_at_primenet.com>
Date: 1997/08/11
Message-ID: <5snl0o$k0r@nntp02.primenet.com>#1/1

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

Original text of this message

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