Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Weeknumber of a year
purush.venkat_at_gmail.com wrote:
> Hi Experts,
>
> I have a question where in i have to get a weeknumber as follows :
>
> Week Week Ending
>
> 1 1/5/2006
> 2 1/12/2006
> 3 1/19/2006
> 4 1/26/2006
> 5 2/2/2006
> 6 2/9/2006
>
> etc. so on and so forth.
>
> Can anyone help me with this in ORACLE 9i please?
>
> Thanks,
> -- Tom .
Starting point - experiment:
Find the number of days, divide by 7, round up, add 1 to the result:
SELECT
CEIL((TRUNC(SYSDATE)-TO_DATE('01/05/2006','MM/DD/YYYY'))/7)+1
FROM
DUAL;
Plugging in a date in place of the current date in the previous
statement:
SELECT
CEIL((TO_DATE('01/04/2006','MM/DD/YYYY')-TO_DATE('01/05/2006','MM/DD/YYYY'))/7)+1
FROM
DUAL;
Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc.
Received on Wed Jul 19 2006 - 16:01:31 CDT