+ Reply to Thread
Results 1 to 4 of 4

COUNTIF query

  1. #1
    Registered User
    Join Date
    09-18-2007
    Posts
    5

    COUNTIF query

    er..I have an excel datasheet where one of the fields has a date value...I'm trying to create a summary stats sheet to go with it.

    What I want to do, in my head, is 'countif ("a value is between THIS date and THAT date")'

    Countif probably isn't the best function, but I'm not an excel expert. Any ideas if/how this is possible?

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening reaper
    Quote Originally Posted by reaper View Post
    What I want to do, in my head, is 'countif ("a value is between THIS date and THAT date")'
    Let's say that you have dates from A1:A20, and you want to count all dates between 01/07/08 and 10/07/08 (these dates are in English format - adjust to suit) then this formula should do the trick :

    =SUMPRODUCT(--(A1:A20>=DATEVALUE("01/07/08")),--(A1:A20<=DATEVALUE("10/07/08")))

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    These are lovely formulae, these sumproduct implicit arrays.

    A couple of side notes:
    As this particular example is a pair of arrays, only single negation is necessary to convert the true/false arrays to numbers (0s and -1s as opposed to 0s and 1s).
    Also, date(year,month,day) has none of the ambiguity of datevalue("string"); an issue DominicB acknowledges

    Following these notes, my ammendment would be:
    =SUMPRODUCT(-(A1:A20>=DATE(2008,7,1)),-(A1:A20<=DATE(2008,7,10)))

    HTH
    Last edited by Cheeky Charlie; 09-03-2008 at 05:38 PM. Reason: clumsy fingers

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    or just put your two dates in cells, e.g. D2 and D3 and use either

    =SUMPRODUCT(--(range>=D2),--(range<=D3))

    or

    =COUNTIF(range,">="&D2)-COUNTIF(range,">"&D3)

+ 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. Excel paste link changes after sql query refresh
    By dest in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-08-2008, 03:41 PM
  2. User-defined variables in MS access query
    By ratzy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-11-2007, 11:13 AM
  3. Pivot Table from MS Query
    By Jim Palmer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-17-2007, 09:42 AM
  4. Excel query and parameters
    By urbanmojo in forum Excel General
    Replies: 1
    Last Post: 07-23-2007, 12:17 AM
  5. Functions with DB Query Reference
    By sushi637 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-25-2007, 12:28 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