Week Number
Rudi Meyer
meyer_rudi@hotmail.com
Mon, 03 Nov 2003 09:49:11 +0200
Hi Mikael
You first need to calculate which day of the year it is (e.g. Today, 3
November 2003 will be day number 307) Having calculated that you can't just
divide that by seven to see which week it is. The second week of the year
does not start on day 8.
Wednesday, 1 January 2003 = Week 1
Sunday, 5 January 2003 = Week 2 ( NOTE: The second week of the year does
not necesarrily start on the same day as New Year. In the case of 2003, the
start of week 2 will be on the first Sunday after new year, i.e. the 5th)
Monday, 3 November 2003 = Week 45
; CODE
acc admin ;just a one-record file
DEFINE run-dt date = parm
DEFINE start-dt date = nconv(asc(run-dt)[1:4] + "0101")
DEFINE dayofyear int*4 = days(run-dt) - days(start-dt) + 1
DEFINE weekspast int*4 = (dayofyear / 7) + 1
DEFINE First-Day-Number NUM*1 = MOD(DAYS(run-dt),7)
DEFINE This-Day-Number num*1 = MOD(Days(start-dt),7)
DEFINE week-no int*3 = (weekspast + 1) if First-day-number < This-day-number
&
else weekspast
rep run-dt dayofyear week-no
go
Regards,
Rudi Meyer
NHA (South Africa)
_________________________________________________________________
Launch into fun online games with MSN Messenger!
http://messenger.msn.co.za/Resource/Games.aspx