+ Reply to Thread
Results 1 to 15 of 15

Looking for a formula that counts between two times

Hybrid View

  1. #1
    Registered User
    Join Date
    03-18-2011
    Location
    Atlanta Georgia
    MS-Off Ver
    Excel 2003
    Posts
    18

    Looking for a formula that counts between two times

    Hi All,
    You guys were such great help on my last issue, that I am coming back for more. :-) I researched how I might do this, but keep getting stumped by part of it.
    I have data over the last 170 days. Each entry has a time stamp. I would like to count how many entries there are between 7:45 am and 2:45pm. A total count across all 170 days is needed, but it would be great if I could break that down by calendar day (i do have that as a column).
    Here is a sample of the data:Friday 11/15/13 07:08AM
    Friday 11/15/13 07:08AM
    Friday 11/15/13 07:16AM
    Friday 11/15/13 07:16AM
    Friday 11/15/13 07:46AM
    Friday 11/15/13 07:46AM

    And the sheet has dates starting in June and ending in mid December.

    Thanks for suggestions.
    Scott

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Looking for a formula that counts between two times

    Try this:
    =SUMPRODUCT((MOD(A1:A170,1)<=TIME(14,45,0))*(MOD(A1:A170,1)>=TIME(7,45,0)))
    and of course - if you would attach a file the formula would have addres to real data. Once there was no attachment you shall instead of A1:A170 put real address of the data for particular day (or add yet another factor inside sumproduct to count for particular day) and test formula by yourself
    Last edited by Kaper; 12-19-2013 at 09:22 AM.

  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,825

    Re: Looking for a formula that counts between two times

    Suppose your example data is in column A and is actual Excel-dates formatted to look like that, and your list of calendar dates is in column D, starting in D2, then you can put this formula in E2:

    =SUMPRODUCT((INT(A$1:A$1000)=D2)*(MOD(A$1:A$1000,1)>=--"7:45:00")*(MOD(A$1:A$1000,1)<=--"14:45:00"))

    Adjust the cell references to suit, then copy down.

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    03-18-2011
    Location
    Atlanta Georgia
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Looking for a formula that counts between two times

    Quote Originally Posted by Pete_UK View Post
    Suppose your example data is in column A and is actual Excel-dates formatted to look like that, and your list of calendar dates is in column D, starting in D2, then you can put this formula in E2:

    =SUMPRODUCT((INT(A$1:A$1000)=D2)*(MOD(A$1:A$1000,1)>=--"7:45:00")*(MOD(A$1:A$1000,1)<=--"14:45:00"))

    Adjust the cell references to suit, then copy down.

    Hope this helps.

    Pete
    Each date element is in its own cell.
    Time is one column, date is one column, and day is one column.
    Does that help??
    Thanks
    Scott

  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,825

    Re: Looking for a formula that counts between two times

    Attach a sample workbook.

    Pete

  6. #6
    Registered User
    Join Date
    03-18-2011
    Location
    Atlanta Georgia
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Looking for a formula that counts between two times

    Here is a sample.
    Thanks
    Scott
    Attached Files Attached Files

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

    Re: Looking for a formula that counts between two times

    Your "times" in column C are text values - to convert them to proper times you can put this formula in D2:

    =(LEFT(C2,5)&":00")+IF(RIGHT(C2,2)="PM",0.5,0)

    Format that cell as TIME, then copy the formula down.

    You can derive the dates in column F using this formula in F2:

    =MIN(B:B)

    and this one in F3:

    =F2+1

    Format both cells as dates, then copy the formula in F3 down as far as you need. Then in G2 you can have this formula:

    =SUMPRODUCT((B$2:B$400=F2)*(D$2:D$400>=--"7:45:00")*(D$2:D$400<=--"14:45:00"))

    (which results in 90 in your sample file), then copy this down for as many dates as you have in column F.

    Hope this helps.

    Pete

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Looking for a formula that counts between two times

    The other option is to do a pivot table out of the data. Filtering timestamps between certain hours could be a bit tricky, but the result will be neatly formatted and include all data just in one step (without creating manually list of dates). Anyway, again sample data in a spreadsheet would make answering easier/more precise.

  9. #9
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Looking for a formula that counts between two times

    other way to have real time from "time like text":
    =TIMEVALUE(LEFT(C2,5)&" "&RIGHT(C2,2))
    Check out in attached file, how (with 2 IFs) it could be used in Pivot Table.
    Attached Files Attached Files

+ 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. Replies: 0
    Last Post: 11-14-2011, 05:40 PM
  2. Counts how many times i enter a number in a particular cell
    By j0hn in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 06-13-2010, 02:25 PM
  3. Replies: 9
    Last Post: 03-16-2010, 03:34 PM
  4. formula that counts
    By excellentexcel in forum Excel General
    Replies: 6
    Last Post: 01-13-2009, 09:48 AM
  5. A cell that counts the number of times...
    By TPD in forum Excel General
    Replies: 1
    Last Post: 02-14-2005, 11:31 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