Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Problem with date conversion
In article <870169462.15286_at_dejanews.com>,
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 format'
>
> Can you help me, please ?
>
> And it's better if you can send a copy by mail...
>
> Thank you.
>
> Bruno Thomas <mailto:bthomas_at_eises.equipement.gouv.fr>
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
The error you got says that the format element 'WW' can only appear in date to char conversions. Try the function below:
function month_from_week(week in number, year in number) return number is
first_day date; first_monday date; day_at_week date;
This function obviously starts with the first whole week of the year. But you can easily modify it for your own needs and add some parameter validation code.
Good Luck.
Emre
-------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to UsenetReceived on Sun Aug 03 1997 - 00:00:00 CDT
![]() |
![]() |