×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Week of the year

Week of the year

Week of the year

(OP)
Here is a small SQL showing that week 1 of the year starts with Jan. 1 and Sunday is day 1 of a week.

CODE

SELECT
    a.d dDate,
    TO_CHAR(a.d, 'Dy') cDay,
    TO_NUMBER(TO_CHAR(a.d, 'd')) nDay,
    TO_NUMBER(TO_CHAR(a.d, 'ww')) nWeek,
    TO_NUMBER(TO_CHAR(a.d, 'ww')) +
        CASE WHEN TO_CHAR(a.d, 'ww') = TO_CHAR((a.d - TO_NUMBER(TO_CHAR(a.d, 'd'))), 'ww')
            THEN 1
            ELSE 0
        END nCorrectWeek
    FROM
        (SELECT
            TRUNC(SYSDATE, 'y') - 1 + ROWNUM d
            FROM All_Objects
            WHERE ROWNUM <= ADD_MONTHS(TRUNC(SYSDATE, 'y'), 12) - TRUNC(SYSDATE, 'y')) a; 

And here is the function version that accepts dates:

CODE

create or replace function THWW 
(
    Date_Entry in date 
)   return number  is

    WWNum number;

begin
    WWNum := TO_NUMBER(TO_CHAR(Date_Entry, 'ww')) +
        CASE WHEN TO_CHAR(Date_Entry, 'ww') = TO_CHAR((Date_Entry - TO_NUMBER(TO_CHAR(Date_Entry, 'd'))), 'ww')
            THEN 1
            ELSE 0
        END;

    return WWNum;
end THWW; 

My question is, knowing that "IW" is the standard, are we the only ones (I mean, the company I work for) that requires such non-standard week numbering? My apologies but it confuses me how they designed the logic of IW and WW.

kilroy knight
philippines

"Once a king, always a king. But being a knight is more than enough."

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close