+ Reply to Thread
Results 1 to 5 of 5

counting days

  1. #1
    Registered User
    Join Date
    04-05-2009
    Location
    Brisbane, Australia
    MS-Off Ver
    Office 365
    Posts
    71

    counting days

    G'Day all,

    I'm trying to devise a formula that will count the amount of saturdays and sundays within a given date range.

    Is this feasible within Excel?
    Last edited by Xtopher; 05-25-2010 at 07:30 PM.
    Regards,
    Xtopher

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting days

    Start Date in A1
    End Date in A2

    This formula will tell you how many Mondays are in the range:

    =INT((A2 - A1 + WEEKDAY(A1 - 2)) / 7)

    The number in RED is the key to what day is being counted.

    1=Sundays
    2=Mondays
    etc....

    Hat tip to Richard Schollar:
    (source)
    Last edited by JBeaucaire; 05-25-2010 at 09:16 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    04-05-2009
    Location
    Brisbane, Australia
    MS-Off Ver
    Office 365
    Posts
    71

    Re: counting days

    Quote Originally Posted by JBeaucaire View Post
    Start Date in A1
    End Date in A2

    This formula will tell you how many Mondays are in the range:

    =INT((A2 - A1 + WEEKDAY(A1 - 2)) / 7)

    The number in RED is the key to what day is being counte.

    1=Sundays
    2=Mondays
    etc....

    Hat tip to Richard Schollar:
    (source)
    Thanks JB, but can this formula support multiple days?

    Saturday & Sunday?

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,723

    Re: counting days

    ....extending that, then, to count both Saturdays and Sundays, you can use this version

    =SUM(INT((A2 - A1 + WEEKDAY(A1 - {1,7})) / 7))

    .....or you could use the NETWORKDAYS formula in reverse. NETWORKDAYS counts non-weekend days so you can subtract that count from a count of the total days in your range, i.e.

    =A2-A1+1-NETWORKDAYS(A1,A2)

  5. #5
    Registered User
    Join Date
    04-05-2009
    Location
    Brisbane, Australia
    MS-Off Ver
    Office 365
    Posts
    71

    Re: counting days

    Quote Originally Posted by daddylonglegs View Post

    =A2-A1+1-NETWORKDAYS(A1,A2)
    Thanks daddylonglegs! That works a treat!

    Brilliance again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1