- business day calculation algorithm
- Posted by surendra singhi on October 20th, 2003
this algorithm counts the number of business weekdays between tow
dates fromdate and todate
//Fromdate is counted as a business day and ToDate is not counted
Date FromDate,ToDate;
// DayOfWeek returns 1 for sunday and 7 for Saturday
int x=FromDate.DayOfWeek();
int y=ToDate.DayOfWeek();
// % means remainder
Date AdvancedFromDate=AddDays(FromDate,(8-x)%7 );
Date PulledToDate=SubtractDays(ToDate,y-1 );
int WeekDays=((AdvancedFromDate-PulledToDate)/7 )*5;
if(x!=1)
WeekDays=WeekDays + 7-x ;
if(y!=1)
WeekDays=WeekDays + y-2;
//i welcome the criticism of group members on the above algo.
- Posted by surendra singhi on November 3rd, 2003
has anybody ever read the post
- Posted by osmium on November 3rd, 2003
surendra singhi writes:
I have now. There is no request for action associated with it so if I saw
it earlier (I think I did) I went right by. If you think you have found
something especially clever you are going to have a hard time raising much
interest in a fundamental area such as the calendar. Also, if you want it
checked for bullet-proof validity, I am not much interested in that either,
although some here are fascinated with such stuff.
- Posted by Paul E. Black on November 3rd, 2003
singhis@ocwen.co.in (surendra singhi) writes:
Yes, but I prefer the Times.
-paul-
--
Paul E. Black (p.black@acm.org)