Get First Day Of Week From Week Number

oracle, plsql

Solution

try this:

select next_day(max(d), 'sun') requested_sun
  from (select to_date('01-01-2012', 'dd-mm-yyyy') + (rownum-1) d from dual connect by level <= 366)
 where to_char(d, 'ww') = 49-1;

just set your year `to_date('01-01-2012'` and week number-1 `49-1` as applicable.

the sunday in the 49th week of 2008?

SQL> select next_day(max(d), 'sun') requested_sun
  2    from (select to_date('01-01-2008', 'dd-mm-yyyy') + (rownum-1) d from dual connect by level <= 366)
  3   where to_char(d, 'ww') = 49-1;

REQUESTED
---------
07-DEC-08

and 2012

SQL> select next_day(max(d), 'sun') requested_sun
  2    from (select to_date('01-01-2012', 'dd-mm-yyyy') + (rownum-1) d from dual connect by level <= 366)
  3   where to_char(d, 'ww') = 49-1;

REQUESTED
---------
02-DEC-12

Problem

In Oracle, is there a straightforward way to get the first day of the week given a week number? For example, today's date is 12/4/2012. If I run: select to_char(sysdate,'WW') from dual; It returns 49 for the week number. What I would like to do is somehow return 12/2/2012 for the first day...given week 49 (assuming Sunday as first day of the week). Any ideas? Thanks in advance for any help!

Original source