Week of year?

John Webster john.webster@cdp.co.nz
Tue, 7 Mar 2000 09:40:28 +1300


There's an ISO standard that covers week numbering, and in a very old
SupportLink I'm sure there's an article on how to calculate it. I'll try
searching my archives, but someone else might know where it is. The User
Group book might be another source - I think it has a section on dates that
covers just about everything...
John Webster
--------
From:	Pickering, John (NORBORD)
Sent:	March  7, 2000 7:01 AM
To:	'jlkeepers@mmm.com'; powerh-l@lists.swau.edu
Cc:
Subject:	RE: Week of year?

Try this one. By "corporate decree" the first week of the year is the first
week with a Wednesday in it. Similarly, Sunday is the first day of the week.
Coded with defines so that it can be used in any of Quick, Qtp or Quiz.

Regards,
JWP

;---------- EMUWKNO - Use file with defines to calculate week number.
;
;    use file takes D-DATE-PARM (8 digit date) and returns
;    week number in D-WEEK-CODE (4 character string) as yyww
;               and D-WEEK-NUMBER (2 digit number) as ww

DEFINE D-YYYY CHAR*4 &
  =    ASCII(DATE(DAYS(LASTDAY(D-DATE-PARM))+1),8)[1:4] &
    IF ("1229" = ASCII(D-DATE-PARM,8)[5:4] AND &
        0 GE MOD(DAYS(D-DATE-PARM),7)) &
    OR ("1230" = ASCII(D-DATE-PARM,8)[5:4] AND &
        1 GE MOD(DAYS(D-DATE-PARM),7)) &
    OR ("1231" = ASCII(D-DATE-PARM,8)[5:4] AND &
        2 GE MOD(DAYS(D-DATE-PARM),7)) &
  ELSE ASC(DATE(DAYS(NCON(ASC(D-DATE-PARM,8)[1:6]+"01"))-1),8)[1:4] &
    IF ("0101" = ASCII(D-DATE-PARM,8)[5:4] AND &
        4 LE MOD(DAYS(D-DATE-PARM),7)) &
    OR ("0102" = ASCII(D-DATE-PARM,8)[5:4] AND &
        5 LE MOD(DAYS(D-DATE-PARM),7)) &
    OR ("0103" = ASCII(D-DATE-PARM,8)[5:4] AND &
        6 LE MOD(DAYS(D-DATE-PARM),7)) &
  ELSE ASCII(D-DATE-PARM,8)[1:4]

DEFINE D-JAN-01 DATE = NCON(D-YYYY+"0101")

DEFINE D-SUNDAY-WEEK-01 DATE &
  =    DATE(DAYS(D-JAN-01) - MOD(DAYS(D-JAN-01),7)) &
    IF 3 GE MOD(DAYS(D-JAN-01),7) &
  ELSE DATE(DAYS(D-JAN-01) - MOD(DAYS(D-JAN-01),7) + 7)

DEFINE D-WEEK-NUMBER INT*2 &
  =    FLOOR((DAYS(D-DATE-PARM) - DAYS(D-SUNDAY-WEEK-01)) / 7) + 1

DEFINE D-WEEK-CODE CHAR*4 &
  =    D-YYYY[3:2] + ASCII(D-WEEK-NUMBER,2)

;--------------------------------------------------------------------




> -----Original Message-----
> From:	jlkeepers@mmm.com [SMTP:jlkeepers@mmm.com]
> Sent:	Monday, March 06, 2000 12:36 PM
> To:	powerh-l@lists.swau.edu
> Subject:	Week of year?
>
>
>
> Does anyone have any powerhouse logic that will calculate what week of the
> year
> the current week is (ie, 10th, 11th, etc)?
>
> Thanks in advance,
>
> Jeff Keepers
>
>
> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> =
> Subscribe: "subscribe powerh-l" in message body to
> majordomo@lists.swau.edu
> Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
> This list is closed, thus to post to the list, you must be a subscriber.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
This list is closed, thus to post to the list, you must be a subscriber.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
This list is closed, thus to post to the list, you must be a subscriber.