+ Reply to Thread
Results 1 to 21 of 21

Count the Saturdays in a list for a specific period.

  1. #1
    Forum Contributor MariaPap's Avatar
    Join Date
    10-19-2013
    Location
    Chania-Crete-Greece
    MS-Off Ver
    Excel 2003-2010
    Posts
    319

    Count the Saturdays in a list for a specific period.

    Hello

    I have a list with dates in column A.

    In E1 type the start date & in E2 the end date.

    I need to count how many Saturdays exist in the list for this period.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Count the Saturdays in a list for a specific period.

    Try

    =SUMPRODUCT(--($A$1:$A$73>=$E$1), --($A$1:$A$73<=$E$2), --(WEEKDAY($A$1:$A$73,1)=7))
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Count the Saturdays in a list for a specific period.

    Try

    =SUMPRODUCT((A1:A73>=E1)*(A1:A73<=E2)*(WEEKDAY(A1:A73)=7))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the Saturdays in a list for a specific period.

    Hi.

    =SUMPRODUCT(0+(A1:A73>=E1),0+(A1:A73<=E2),0+(WEEKDAY(A1:A73)=7))

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Valued Forum Contributor
    Join Date
    04-09-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2010
    Posts
    391

    Re: Count the Saturdays in a list for a specific period.

    Hi,

    Try below array formula in 2007+

    =SUM(--(IFERROR(WEEKDAY(IF(($A$1:$A$73>=E1)*($A$1:$A$73<=E2),$A$1:$A$73,"e"),2),0)=6))

    Confirm with Cntl+Shift+Enter.

  6. #6
    Forum Contributor MariaPap's Avatar
    Join Date
    10-19-2013
    Location
    Chania-Crete-Greece
    MS-Off Ver
    Excel 2003-2010
    Posts
    319

    Re: Count the Saturdays in a list for a specific period.

    Thank you all.

    May i ask(as i have more than 25000 rows with dates in column A) if we can do this using some other function than SUMPRODUCT, that as i learned here is-in fact- an ARRAY formula?

  7. #7
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Count the Saturdays in a list for a specific period.

    Hmm..Use a helper column perhaps?

    =--AND(A1>=$E$1,A1<=$E$2,WEEKDAY(A1)=7)

    Copy down, then sum this column

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the Saturdays in a list for a specific period.

    @misrasomendra

    Ah! So you use this array construction with IFERROR and "e" in all your formulas!

    Very original! (Though of course a CSE formula is not necessary here, and I have to add that we really should try to avoid IFERROR if possible. Still, points for creativity!)

    Regards

  9. #9
    Valued Forum Contributor
    Join Date
    04-09-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2010
    Posts
    391

    Re: Count the Saturdays in a list for a specific period.

    @XOR LX,

    Can you believe when I tested all the four formula above on the given data set, mine is fastest

    Regards,

  10. #10
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Count the Saturdays in a list for a specific period.

    try this..
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the Saturdays in a list for a specific period.

    Quote Originally Posted by misrasomendra View Post
    @XOR LX,

    Can you believe when I tested all the four formula above on the given data set, mine is fastest

    Regards,
    Actually, no! I can't believe that! How much faster?

    Can you post the details of your testing?

    Regards

  12. #12
    Valued Forum Contributor
    Join Date
    04-09-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2010
    Posts
    391

    Re: Count the Saturdays in a list for a specific period.

    Quote Originally Posted by XOR LX View Post
    Actually, no! I can't believe that! How much faster?

    Can you post the details of your testing?

    Regards

    See the file. Time are in Seconds.

    Regards,
    Attached Files Attached Files

  13. #13
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the Saturdays in a list for a specific period.

    Thanks. I stand corrected. Interesting.

    I still think that the minute difference in speed does not quite make up for the lack in comprehensibility, nor for the necessary use of an IFERROR.

    Still, I'd be curious to know of the underlying technical reasons why this version slightly outperforms the alternatives.

    And I suppose if we were talking of a situation concerning hundreds of thousands of rows then it may be worth considering.

    Regards

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Count the Saturdays in a list for a specific period.

    If the dates are always sequential as in the example,

    =SUM(INT((WEEKDAY(E1 - {7}) + E2 - E1)/7))

    The {7} can be expanded to include additional days, e.g., for Wednesdays and Saturdays,

    =SUM(INT((WEEKDAY(E1 - {4,7}) + E2 - E1)/7))

    Complements of DLL.
    Last edited by shg; 10-28-2014 at 10:35 AM.
    Entia non sunt multiplicanda sine necessitate

  15. #15
    Valued Forum Contributor
    Join Date
    04-09-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2010
    Posts
    391

    Re: Count the Saturdays in a list for a specific period.

    @XOR LX

    This was for fun, I came up with this technique while using it with FREQUENCY function. I don't remember the problem or day, but from that day I always used it.

    Although, I understand that over the data set of Million or more rows, results might not be same. I had seen other situations where An array formula results in lesser time as compared to non-array solution.

    Regards,

  16. #16
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Count the Saturdays in a list for a specific period.

    Hi Somendra,
    Can you believe when I tested all the four formula above on the given data set, mine is fastest
    By saying the above quoted lines, you are saying that using Nested Ifs is more faster than using Array Multiplication..
    But our expert Mr. TMS or TONY VOLKO ( I Don't remember ) has proved me, using the codes below, that using Array multiplication is more
    faster... so here are my questions..

    How did you tested the speed ...?
    Did you use the code in the link below..?
    http://msdn.microsoft.com/en-us/libr...ffice.12).aspx

    However, if this is faster
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Then this can be more faster..( Arrayed formula )
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Waiting for reply..
    Regards,
    Last edited by Vikas_Gautam; 10-27-2014 at 10:31 PM.

  17. #17
    Valued Forum Contributor
    Join Date
    04-09-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2010
    Posts
    391

    Re: Count the Saturdays in a list for a specific period.

    @Vikas_Gautam,

    Yes I did use the code in the link that you mentioned and Not once but at least 6 times on each formula.

    Regards,

  18. #18
    Forum Contributor MariaPap's Avatar
    Join Date
    10-19-2013
    Location
    Chania-Crete-Greece
    MS-Off Ver
    Excel 2003-2010
    Posts
    319

    Re: Count the Saturdays in a list for a specific period.

    Thank you ALL!

  19. #19
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Count the Saturdays in a list for a specific period.

    Hi,

    a possible (late) approach


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Cheers


    edit:weekday =1 (Sundays)
    Last edited by canapone; 10-28-2014 at 04:28 AM.
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  20. #20
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count the Saturdays in a list for a specific period.

    @canapone

    Doesn't it also have to meet the condition of being within the range A1:A73?

    Regards

  21. #21
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Count the Saturdays in a list for a specific period.

    Hi,

    good point: sorry I've totally misunderstood the OP needs. I was considering A1:A73 as an helper range.

    Not sure the following could be a robust formula:


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Regards


    Late Edit: Weekday = 1
    Last edited by canapone; 10-28-2014 at 04:28 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copy a specific range to another sheet adding all the workdays for a specific time period
    By MariaPap in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-05-2014, 02:19 AM
  2. [SOLVED] Count the number of Saturdays that have passed in a month so far
    By Badvgood in forum Excel General
    Replies: 9
    Last Post: 03-16-2014, 04:07 PM
  3. [SOLVED] Count no of Saturdays within a given period
    By prashantha in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-19-2013, 06:21 AM
  4. Formula to not count hours before and after a specific set time period
    By Chrislawsin in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-16-2012, 06:29 PM
  5. Formula count occurences in a specific time period
    By sarahmad in forum Excel General
    Replies: 7
    Last Post: 10-26-2009, 01:33 PM

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