calculate weekdays

Discussion in 'ASP .Net' started by Mike, Jul 11, 2008.

  1. Mike

    Mike Guest

    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?
    Mike, Jul 11, 2008
    #1
    1. Advertising

  2. Mike

    Mike Guest

    I'll give this a shot, Its for an internal app so Saturday and Sunday are
    weekends.

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Mike" <> wrote in message
    > news:eDH%...
    >
    >> 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/06/understanding-datetime-and-timespan-in.html
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    Mike, Jul 14, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marlon
    Replies:
    1
    Views:
    2,198
    Tom Kaminski [MVP]
    Sep 10, 2004
  2. hupjack
    Replies:
    4
    Views:
    762
    hupjack
    May 5, 2004
  3. Jive Dadson

    weekdays in range

    Jive Dadson, Oct 18, 2009, in forum: Python
    Replies:
    4
    Views:
    318
    Jive Dadson
    Oct 18, 2009
  4. JP SIngh

    Calculate Weekdays in ASP

    JP SIngh, Jul 13, 2004, in forum: ASP General
    Replies:
    2
    Views:
    193
    Aaron [SQL Server MVP]
    Jul 13, 2004
  5. SimonC
    Replies:
    5
    Views:
    363
    Dr John Stockton
    Jan 27, 2005
Loading...

Share This Page