+ Reply to Thread
Results 1 to 8 of 8

Countif of Hours and Mins not dates

Hybrid View

  1. #1
    Registered User
    Join Date
    11-16-2008
    Location
    Dubai
    Posts
    73

    Countif of Hours and Mins not dates

    Afternoon all

    I have a data feed that gives a column of cells formated mm/dd/yy hh:mm
    These are call entries, what i want to do is count all the occurances each hour, so count all the entries say between 9am and 10am. However the column is very long and holds data for many weeks so i want to be able to ignore the date part of the cell.

    For example

    3/17/09 9:58
    3/18/09 10:58
    3/18/09 8:58
    3/19/09 8:58
    3/19/09 9:58
    3/19/09 9:58

    So the entries between 9 and 10 are = 3

    Ideally i do not want to do text to colums and split out the parts. i would like to leave the source data alone.

    Nick
    Last edited by Nick_in_Dubai; 03-17-2009 at 08:51 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Countif of Hours and Mins not dates

    Nick, really you should use a PT for this... you can set your DateTime Column to be ROW Field and Group by Hour only... you can then have DateTime Column in Data Field also set to COUNT. This is far and away the best method available to you... ie will give you an hourly breakdown.

    EDIT: If you are interested in only one time span then a SUMPRODUCT should suffice: =SUMPRODUCT(--(HOUR(MOD(A2:A7,1))=C2)) where C2 = Start hour of interest (9) ... to reiterate though for multiple results use a PT (purpose built)
    Last edited by DonkeyOte; 03-17-2009 at 05:43 AM.

  3. #3
    Registered User
    Join Date
    11-16-2008
    Location
    Dubai
    Posts
    73

    Re: Countif of Hours and Mins not dates

    yeah a PT would be best but not available to me in this instance, their are many other colums for different info types all linking into an easy presentatiion for the end user.

    The colum is not huge a few hundread entries, i have set up sumproducts for other parts but this is all i have left. Is their a way count?

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Countif of Hours and Mins not dates

    See my EDIT.

  5. #5
    Registered User
    Join Date
    11-16-2008
    Location
    Dubai
    Posts
    73

    Re: Countif of Hours and Mins not dates

    Thats great thanks, to throw one more item into the mix though, Lets say their is also a column say C that has either a yes or a no, can i join:

    =COUNTIF($B$1:$B$1000,"<"&TEXT(D2/24,"0.000"))-SUM(E$1:E1)
    With a sumproduct so that in colum E it shows all the entries that are at 9 and are Yes? and repeated down for all the hour bands....

    ?? Cheers

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Countif of Hours and Mins not dates

    Adapt the earlier SUMPRODUCT

    D2: 9
    E2: =SUMPRODUCT(--(HOUR(MOD($A$2:$A$7,1))=$D2),--($C$2:$C$7="Yes"))
    copy down as required where D3 etc hold hours of interest.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Countif of Hours and Mins not dates

    Hi Nick,

    One other way....
    Assuming your dates and times are in column A, if you use a helper column B adjacent to your date/times and enter
    =A1-INT(A1)
    and copied down,

    Then create a table of hours from 1 to 24, in say D2:D25 and in E2 enter
    =COUNTIF($B$1:$B$1000,"<"&TEXT(D2/24,"0.000"))-SUM(E$1:E1)
    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  8. #8
    Registered User
    Join Date
    11-16-2008
    Location
    Dubai
    Posts
    73

    Re: Countif of Hours and Mins not dates

    Thats great thanks both...............

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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