` Week of year (Michael Euler ) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

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 April 28, 2024, 1:39 pm
This article has been viewed 35107 times.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: