vippsupport.xerox.com    Forums  Hop To Forum Categories  - Xerox FF VI Suite Forum-  Hop To Forums  FF VI Suite (VIPP)    Week number

Moderators: Carlo Sans, jbouche
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Posted
Does anyone have a good hook for computing the week number from a date provided in a print file?

1012 = week 42
Thanks!!


Just Some Guy
 
Posts: 99 | Location: Toledo, Ohio | Registered: 26 February 2001Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
The trick is the last/first week of the year. If it has 4 days in the new year it's week 1 else it's week 52 or 53.

Assuming the year, month and day have been extracted from the date (using GETINTV) into VARyear, VARmonth and VARday, the following code should compute the week:
/VARday [VARyear VARmonth VARmday] DAYS SETVAR
/VARday [VARyear 1 1] DAYS SUB % day in year
[VARyear 1 1 ] SETDATE
CASE D_DWS {}                  % 1/1 day of week 
(Tue) { /VARday 1 ADD }
(Wed) { /VARday 2 ADD }
(Thu) { /VARday 3 ADD }
(Fri) { /VARday 3 SUB }
(Sat) { /VARday 2 SUB }
(Sun) { /VARday 1 SUB }
ENDCASE

IF VARday 0 lt			% 1st days of year
  { /VARlast [VARyear'-'1 12 31] DAYS SETVAR
    /VARlast [VARyear'-'1 1 1] DAYS SUB % day in year of previous 12/31
    [VARyear'-'1 1 1 ] SETDATE
    CASE D_DWS {}                       % 1/1 day of week of previous year
    (Tue) { /VARlast 1 ADD }
    (Wed) { /VARlast 2 ADD }
    (Thu) { /VARlast 3 ADD }
    (Fri) { /VARlast 3 SUB }
    (Sat) { /VARlast 2 SUB }
    (Sun) { /VARlast 1 SUB }
    ENDCASE
    /VARweek VARlast'q'7'+'1 SETVAR % same week as 12/31
  }
ELSE
  { /VARweek VARday'q'7'+'1 SETVAR
    IF VARweek 53 eq VARday'-'VARmday 336 lt and  % last week of year < 4 days
      { /VARweek 1 SETVAR }
     ENDIF
  }
ENDIF
GETDATE  % reset current date
 
Posts: 1766 | Location: Switzerland | Registered: 04 May 2001Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
As always... perfect solution... thanks for the help!!


Just Some Guy
 
Posts: 99 | Location: Toledo, Ohio | Registered: 26 February 2001Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 

    vippsupport.xerox.com    Forums  Hop To Forum Categories  - Xerox FF VI Suite Forum-  Hop To Forums  FF VI Suite (VIPP)    Week number