+ Reply to Thread
Results 1 to 5 of 5

How Many Times an Hour Occurs Between Two Dates

  1. #1
    Registered User
    Join Date
    05-05-2011
    Location
    Reno
    MS-Off Ver
    Excel 2003
    Posts
    6

    How Many Times an Hour Occurs Between Two Dates

    Hello,

    I have a sheet that is set up with 2 columns that have dates and times.

    E.g. Col A has 10/1/10 17:08 and column B has 10/5/10 7:35.

    I am wondering if anyone knows of a way to calculate how many times a particular hour occurs between those two times. For example, in the time range above, 11:00 would occur 3 times.

    Thanks for your help!

  2. #2
    Registered User
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    16.45
    Posts
    35

    Re: How Many Times an Hour Occurs Between Two Dates

    can you send a copy of your excel problem?

  3. #3
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How Many Times an Hour Occurs Between Two Dates

    Try this (not tested other than your sample)

    =IF(HOUR(C2)>=HOUR(A2),1,0)+IF(HOUR(C2)<=HOUR(B2),1,0)+INT(B2)-INT(A2)-1

    where first date/time is in A2, second date/time is in B2 and hour to check is in C2

    Use this version if you want a result of 3 using the same dates/times but an hour of 17:00

    =IF(HOUR(C2)<=HOUR(A2),0,1)+IF(HOUR(C2)<=HOUR(B2),1,0)+INT(B2)-INT(A2)-1
    or maybe even
    =IF(OR(HOUR(C2)>HOUR(A2),TIME(HOUR(A2),MINUTE(A2),0)=0+C2),1,0)+IF(HOUR(C2)<=HOUR(B2),1,0)+INT(B2)-INT(A2)-1

    it depends on how you want to treat the hour on the start date.
    Last edited by Cutter; 05-16-2011 at 08:32 PM. Reason: Alternative formula

  4. #4
    Registered User
    Join Date
    05-05-2011
    Location
    Reno
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How Many Times an Hour Occurs Between Two Dates

    Thanks Cutter, the first one worked perfectly for me!

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How Many Times an Hour Occurs Between Two Dates

    You're welcome. Don't forget to mark your thread as SOLVED (see FAQ at top of page for directions if needed).

+ 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