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

Home -> Community -> Usenet -> c.d.o.tools -> Re: convert a week to a date?

Re: convert a week to a date?

From: Patrick Diks <patrick.diks_at_capgemini.nl>
Date: 2000/07/04
Message-ID: <3961F98C.E4070F69@capgemini.nl>#1/1

Ai that's a tricky one. The trouble is that you can't use 'WW' as an input date format.
You should try something like this (the constant is the input weeknumber):

declare

  firstdayofyear date;
  firstdayofweek date;
  lastdayofweek  date;
  firstweek      number;
  tryweek        constant number := 51;

begin
  firstdayofyear := to_date('20000101','yyyymmdd');   firstweek := mod(to_number(to_char(firstdayofyear,'WW')),52);   firstdayofweek := trunc(firstdayofyear + 7*(firstweek+tryweek-1),'D');   lastdayofweek := trunc(firstdayofyear + 7*(firstweek+tryweek),'D')-1;   dbms_output.put_line (to_char(firstdayofweek,'day dd month yyyy'));   dbms_output.put_line (to_char(lastdayofweek,'day dd month yyyy')); end;
/

Patrick Diks

pepijn wrote:

> Does anyone know how to convert a weeknumber to the first and last day of
> the week?
>
> e.g.
>
> input: week <n>
>
> output: week <n> starts on monday <date> and ends on sunday <date>
>
> thanks ahead,
>
> Pepijn
Received on Tue Jul 04 2000 - 00:00:00 CDT

Original text of this message

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