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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to convert YYYYWW to date

Re: How to convert YYYYWW to date

From: Maciej Zoltowski <mzoltowski_at_eragsm.com.pl>
Date: Sat, 09 Jan 1999 09:40:21 +0100
Message-ID: <369715F5.83C8E7CE@eragsm.com.pl>


Hello
What you want to do is: to find the end of the first week in the year and then add appropriate number of days.

select next_day(to_date(substr('&yearweek', 1, 4), 'YYYY'),'SATURDAY')

         + 7*(substr('&yearweek', 5)-1)
from dual

Note that if the New Year is on the last day of the week (like on jan-01-2000) you get the end of the next week (jan-08-2000). If it is not correct for you, do

select next_day(to_date(substr('&yearweek', 1, 4), 'YYYY')-1,'SATURDAY')

         + 7*(substr('&yearweek', 5)-1)
from dual

--

-- Maciej Zóltowski -------------------
	e-mail: mzoltowski_at_eragsm.com.pl
	phone:	 +48 (22) 6996040
	mobile: +48 602 206040
---------------------------------------

Steve Perry wrote:
>
> I have a table that has a column year_week stored as a number. Is
> there an easy way to convert this to date.
> For example: 199901 would be converted to jan-02-1999 ( the last day
> of the week for week 1 of 1999)
> 19902 would be jan-09-1999...
>
> I thought it would be pretty easy using the to_char and to_date, but
> it's more of a problem than I thought.
>
> Can somebody get me started in the right direction.
>
> Thanks,
> Steve
Received on Sat Jan 09 1999 - 02:40:21 CST

Original text of this message

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