+ Reply to Thread
Results 1 to 9 of 9

Struggling with dates and COUNTIF

Hybrid View

  1. #1
    Registered User
    Join Date
    06-10-2012
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2007
    Posts
    17

    Struggling with dates and COUNTIF

    Hi,

    I am importing a series of data from a database that includes dates and a timestamp. I don't really care about the timestamp.

    One sheet has the imported data and data in the "timeout" column has a value like: "6/28/2012 4:18:17 PM"

    On another sheet I am trying to count how many data entries there are for a specific date. The data in the comparison cell looks like: "6/28/2012"

    I have tried a variety of COUNTIF statements, including:
    =COUNTIF('IMPORTED DATA'!E:E,A2&"*")

    None seem to be working for me. All attempts have yielded a value of 0. When I can see that the value should be greater.

    Any guidance is appreciated.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Struggling with dates and COUNTIF

    what happens when either of those cells containing dates is formatted general?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Struggling with dates and COUNTIF

    just something to note...if those 2 values are in fact values, 6/28/2012 4:18:17 PM is NOT the same vale as 6/28/2012

    the 1st 1 is actually 41088.6793634259 while the 2nd 1 is actually 41088, so searching for the 1st (or the 2nd) will not find the other.

    if, on the other hand, those "dates" are text, then again the cell contents will not match due to the time added to the 1st entry.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    06-10-2012
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Struggling with dates and COUNTIF

    @ martindwilson - the cells return values as FDibbins describes.

    @ FDibbins - Right. And that is my crux. I am hoping that there is some way to incorporate a wild card. Essentially, a "Like" statement. I am hoping to avoid a converter column or worse a converter sheet (since I have a few different date entries in separate columns that will require similar filtering).

    If I change the format to general the issue that I face is that I need the values of the range to be an integer. I do not see a way that excel will allow me to control the value of the range. example: =COUNTIF((INT('Full Report'!E:E)),A2) will result in an error.

  5. #5
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Struggling with dates and COUNTIF

    hello can you try this one..

    =SUMPRODUCT(--(DAY('Full Report'!$E$1:$E$100)=DAY(A2)),--(MONTH('Full Report'!$E$1:$E$100)=MONTH(A2)),--YEAR('Full Report'!$E$1:$E$100)=YEAR(A2))
    EDIT: typo error in range..
    Last edited by vlady; 07-28-2012 at 10:42 PM. Reason: typo error in ranges
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Struggling with dates and COUNTIF

    try as long as there are no empty cells in the range
    Formula: copy to clipboard
    =SUMPRODUCT(--(TEXT('imported data'!E1:INDEX('imported data'!E:E,COUNTA('imported data'!E:E)),"dd/mm/yyy")+0=A2))
    Last edited by martindwilson; 07-29-2012 at 06:52 AM.

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Struggling with dates and COUNTIF

    As the OP is using 2007 how about

    Formula: copy to clipboard
    =COUNTIFS('IMPORTED DATA'!E:E,">="&A2,'IMPORTED DATA'!E:E,"<"&A2+1)

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Struggling with dates and COUNTIF

    after seeing above which should be used
    if and only if
    you need this to work preexcel 2007 then an alternative is
    =SUMPRODUCT(('imported data'!E1:E100>=A2)*('imported data'!E1:E100<A2+1))

  9. #9
    Registered User
    Join Date
    06-10-2012
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Struggling with dates and COUNTIF

    I only tried martindwilson's final suggestion and that worked great!

    Thanks!

+ 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