plsql - use to_date oracle function using week number and day number oracle -
i'm trying date day of week number , week of month number.
for example, have table called club
stores on day , week exams available, has dayofexam
, weekofexam
attributes.
dayofexam=2 (monday). weekofexam=1
that means exams available on every monday of first week of each month. , need 04-jan-2016 ... 08-feb-2016 .. 07-mar-16 , on....
i tried using like
to_date('21012016','dwmmyyyy');
is possible date? thanks.
in sql, can use next_day
, add multiple of 7 days. if want return date each month in year, can this. if want more months, can adjust starting date , number of months go forward.
with x ( select 2 dayofexam, 1 weekofexam dual ), first_of_month ( select add_months( date '2016-01-01', level-1 ) mnth, dayofexam, weekofexam x connect level <= 12 ) select next_day( mnth, dayofexam ) + 7 * (weekofexam - 1) the_date first_of_month;
Comments
Post a Comment