Login
`
Templates, Tools and Utilities
|
||
Icetips Article
Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
Par2: Week of year 2001-01-17 -- Michael Euler Ok, this is my approach, which worked for years now.
Calc_Week FUNCTION(Date)
Code
Week# = 0
if Date[1:2] < 1 or Date[1:2] > 31 or Date[3:4] < 1 or Date[3:4] > 12
return 0
end
Day# = Date[1:2]
Month# = Date[3:4]
Year# = Date[5:8]
First_Day# = (Date(1,1,Year#) % 7) + 1 ! first day of year (1=Sunday)
if First_Day# < 6
NumOf_Days# = First_Day# + 4
else
case First_Day#
of 6
NumOf_Days# = 3
of 7
NumOf_Days# = 4
of 1
NumOf_Days# = 5
end
end
Days_Year# = date(month#,day#,year#) - date(1,1,year#) + 1 ! 'gone' days
All_Days# = Days_Year# + NumOf_Days#
Week# = Int(All_Days# / 7)
if Week# < 1
Week# = 53
end
return Week#
Today is November 21, 2024, 3:36 am This article has been viewed 35210 times.
|
|