+ Reply to Thread
Results 1 to 12 of 12

Formula for hours between two times

  1. #1
    Forum Contributor
    Join Date
    02-15-2012
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2019
    Posts
    431

    Formula for hours between two times

    Hi,

    I need formulas for Hours between two times.

    Attached excel file with relevant details.

    Pl. help.

    thanks,
    Nagesh.
    Attached Files Attached Files

  2. #2
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: Formula for hours between two times

    Hi,

    Something like this?
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    02-15-2012
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2019
    Posts
    431

    Re: Formula for hours between two times

    Hi,

    in Column "H", I actually need the count (No. of vehicles between the respective hours).

    Pl. provide the formula.

    thanks,
    Nagesh.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,373

    Re: Formula for hours between two times

    =SUMIFS($E$3:E$14,E$3:E$14,">00",$E$3:$E$14,",<=1") in H4

    =SUMIFS($E$3:E$14,E$3:E$14,">1",$E$3:$E$14,"<=2") in H5 etc

    =SUMIFS($E$3:E$14,E$3:E$14,">4") in H8

    etc

  5. #5
    Forum Contributor
    Join Date
    02-15-2012
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2019
    Posts
    431

    Re: Formula for hours between two times

    I tried and got it. =(COUNTIFS(E$3:E$14,">0")-COUNTIF(E$3:E$14,">1"))

    Hope this is correct.

    Thanks.

  6. #6
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: Formula for hours between two times

    Hi,

    See the attached file
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    02-15-2012
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2019
    Posts
    431

    Re: Formula for hours between two times

    Hi John,

    in H5 as per your formula getting answer 2 but as per my formula answer coming 1. Even H8 I am getting result 9 as per your formula but as per mine, it is 0 (nil).

    Anyhow thanks.
    Nagesh.

  8. #8
    Forum Contributor
    Join Date
    02-15-2012
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2019
    Posts
    431

    Re: Formula for hours between two times

    Hi cbatrody,

    Even there is difference between mine and your result in H4. My answer is 0 and your 2.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,373

    Re: Formula for hours between two times

    =COUNTIFS($E$3:$E$14,">0",$E$3:$E$14,",<=1") etc

  10. #10
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: Formula for hours between two times

    Quote Originally Posted by nagesh.tvsr View Post
    Hi cbatrody,

    Even there is difference between mine and your result in H4. My answer is 0 and your 2.
    yes, there are 2 vehicles with "0" which are row 5 and row 13

    If you want H4 to be "0", change the formula in H4 as following:

    =COUNTIFS(E$3:E$14,">"&0,E$3:E$14,"<="&1,B$3:B$14,"<>"&"")

  11. #11
    Forum Contributor
    Join Date
    02-15-2012
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2019
    Posts
    431

    Re: Formula for hours between two times

    Hi cbatrody and John,

    Now the results are matching with you both.

    By the way, is there anything wrong with this formula? Because this looks to be simple.

    =(COUNTIFS(E$3:E$14,">0")-COUNTIF(E$3:E$14,">1"))
    =(COUNTIF(E$3:E$14,">=1")-COUNTIF(E$3:E$14,">2"))
    =(COUNTIF(E$3:E$14,">=2")-COUNTIF(E$3:E$14,">3")) ...... and so on.

    Anyhow thank you.

  12. #12
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: Formula for hours between two times

    You can work with those formulae as well if you wish to, they are simple and gives the required output.

+ 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. [SOLVED] Need a Formula to work out break times from hours
    By cymrodan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-01-2014, 09:26 AM
  2. Formula to Calculate the Number of Hours Between 2 Dates and Times
    By Squint in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-11-2014, 03:28 PM
  3. [SOLVED] Formula involving times not working for specific hours, e.g. 22:00
    By kenle11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-07-2013, 11:51 PM
  4. Replies: 7
    Last Post: 02-17-2013, 01:16 AM
  5. [SOLVED] Formula to work out hours between 2 dates and times.. MINUS Out Of Hours
    By chris.m in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-30-2012, 08:11 AM

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