Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > calculate weekdays

Reply
Thread Tools

calculate weekdays

 
 
Mike
Guest
Posts: n/a
 
      07-11-2008
Is there a way to calculate the total number of weekdays when provided a
date?

Example:
If I have a start date of 7/11/2008 and I want to go out 10 days, I want to
get this:

6 weekdays
4 weekend days

Is something like this possible?


 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      07-14-2008
I'll give this a shot, Its for an internal app so Saturday and Sunday are
weekends.

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Mike" <(E-Mail Removed)> wrote in message
> news:eDH%(E-Mail Removed)...
>
>> Is there a way to calculate the total number of weekdays when provided a
>> date?
>>
>> Example:
>> If I have a start date of 7/11/2008 and I want to go out 10 days, I want
>> to get this:
>>
>> 6 weekdays
>> 4 weekend days
>>
>> Is something like this possible?

>
> Simple enough with a bit of programming
>
> Instantiate a DateTime variable from the starting date.
>
> Set up a while loop which increases the DataTime variable using the
> AddDays(1) method for the required number of iterations.
>
> At each iteration, inspect the DataTime variable's DayOfWeek property. If
> it equates to DayOfWeek.Saturday or DayOfWeek.Sunday, treat it differently
> from the other days. Of course, not every culture considers Saturday and
> Sunday to be the weekend, so you might need to check for that...
>
> http://dotnetguts.blogspot.com/2007/...mespan-in.html
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
weekdays in range Jive Dadson Python 4 10-18-2009 11:04 AM
Calculate the number of WEEKDAYS between 2 dates? SimonC Javascript 5 01-27-2005 02:27 PM
calculate the download and upload time .. HELP!! Marlon ASP .Net 1 09-10-2004 12:39 PM
Calculate Weekdays in ASP JP SIngh ASP General 2 07-13-2004 01:17 PM
Script to calculate remaining minutes hupjack Perl 4 05-05-2004 03:42 PM



Advertisments