fullercattle
New Member
I am writing an application in ASP .NET (using VB) which has two textboxes to allow users to enter a start date and an end date. I need to figure out the number of days they have selected based on the range between the start date and end date, which I can do using the DateDiff function. The problem lies in that I need to filter out weekends and holidays. I'm having trouble figuring out how to take two dates, iterate through the values in between and filter out the dates I don't want. I think the solution goes something like this, though:<BR><BR>For example, a user selects 6/27/2002 - 7/6/2002:<BR><BR>1) Figure out total of days selected in between range using DateDiff (total from above: 9)<BR><BR>2) Loop through each day in the range (how? using something like DateAdd(DateInterval.Day, 1, Cdate(tbDate.Text)) ? )<BR><BR>3) Determine if day is a weekend (using DatePart function? or DayOfWeek property? what if date is a holiday? how to check this against a hard-coded list of holidays?), if true filter out (6/29, 6/30 & 7/6 are weekends -- toss out. 7/4 is a holiday -- toss out)<BR><BR>4) Get new total number of days selected, w/ weekends and holidays filtered out (total after filter: 5)<BR><BR>I think I'm on the right track, but I'm a newer developer and can't put together the logic to make this happen. If anybody could give me a hand, (I could write some big promise here, but in reality I'll just be happy and thank you).<BR><BR>Thanks<BR>John<BR>