+ Reply to Thread
Results 1 to 7 of 7

Count the number of dates between a date range

  1. #1
    Forum Contributor
    Join Date
    01-25-2013
    Location
    nottingham
    MS-Off Ver
    Excel 2007
    Posts
    128

    Count the number of dates between a date range

    Hello

    Attached is the sample worksheet. On the Charts sheet, i am trying to create a formula (in cell D25) which count the number of dates in column B on the Unsourced List 2015 sheet which is inbetween the two dates in A25 and B25 on the Charts Sheet

    The formula i am currently using is below and just returns 0 for Q1, although it should be 73

    Please Login or Register  to view this content.
    Thank You

    SAMPLE.xls

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Count the number of dates between a date range

    B2 on Unsourced List is indeed a date
    B3:B228 on Unsourced List are not

    in Unsourced List!I2
    =ISNUMBER(B2)
    copy down the column
    You get one TRUE and the rest are FALSE

    Dates on your Charts are indeed dates

    Change the offending dates or amend the SUMPRODUCT to correct this.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Count the number of dates between a date range

    All but one of your dates in column B are text values. To change them you can highlight the data in column B and then click on Data | Text-to-Columns, then click Fixed Width | Next | Next and on the third panel click against Date with DMY selected and click Finish.

    You can also simplify your formula in D25 to this:

    =COUNTIFS('Unsourced List 2015'!B:B,">="&A25,'Unsourced List 2015'!B:B,"<="&B25)

    as SUMPRODUCT doesn't work very efficiently with full-column references (you also had a misplaced bracket).

    Hope this helps.

    Pete

  4. #4
    Forum Contributor
    Join Date
    01-25-2013
    Location
    nottingham
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Count the number of dates between a date range

    surely if this was the case, it would return 1 instead of 0?

    The dates on the unsourced list have a ' attached at the front which is why it returns false. Due to the data which i retrieve has this inputted already on it, i can't change it unless i can place something in a macro to remove the '

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Count the number of dates between a date range

    Your SP formula should be:

    =SUMPRODUCT(('Unsourced List 2015'!B:B>=Charts!A25)*('Unsourced List 2015'!B:B<=Charts!B25))

    Note the bracket at the end and one removed from the middle. Better to use COUNTIFS, though, as in my previous post. For either of these formulae, you need to have proper dates in column B, and my previous post tells you how you can convert them quite easily.

    Hope this helps.

    Pete

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Count the number of dates between a date range

    Actually, your formula has a slight syntax issue..a Misplaced )

    =SUMPRODUCT(('Unsourced List 2015'!B:B>=Charts!A25))*('Unsourced List 2015'!B:B<=Charts!B25)
    should be
    =SUMPRODUCT(('Unsourced List 2015'!B:B>=Charts!A25)*('Unsourced List 2015'!B:B<=Charts!B25))

    This corrected version indeed does return 1 without modifying any dates on the Unsourced list sheet..

  7. #7
    Forum Contributor
    Join Date
    01-25-2013
    Location
    nottingham
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Count the number of dates between a date range

    Thank you for your help!

+ 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] Count number of rows within a range of dates
    By mikkelsl in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-10-2014, 05:24 PM
  2. Count number of dates in a range by using greater or less than
    By sclasen24 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-18-2013, 01:29 PM
  3. Count the number of VALID dates in range
    By diesellam in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 10-12-2007, 01:40 PM
  4. Replies: 25
    Last Post: 09-07-2005, 12:05 AM
  5. [SOLVED] count number of years 2003 in a range of dates
    By Stan Altshuller in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-03-2005, 03:06 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