+ Reply to Thread
Results 1 to 5 of 5

Count Hours between 2 dates

  1. #1
    Registered User
    Join Date
    07-16-2019
    Location
    Lisbon, Portugal
    MS-Off Ver
    Office 365
    Posts
    3

    Thumbs up Count Hours between 2 dates

    Hello Forum,

    I'm trying to add a column that gives me the hours between 2 dates/times.

    From what I've searched i found how to count weekdays from a start and end hour, how to count if the weekend days are on other days, but I cant find for my problem.

    I need to count the hours occurred between 09AM and 09PM (12h/7days).
    Example:
    01/01/2019 09:30 > 02/01/2019 10:00 = 12:30H


    Thanks
    Last edited by tacpc; 07-17-2019 at 08:05 AM. Reason: Solved. Thanks

  2. #2
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    484

    Re: Count Hours between 2 dates

    See if the following formula works for you:

    =MAX(0,21/24-MOD(A1,1))+MAX(0,MOD(B1,1)-9/24)+(INT(B1)-INT(A1)-1)/2

  3. #3
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Count Hours between 2 dates

    Or try:

    =DATEDIF(A1,B1,"d")/2+MEDIAN(MOD(B1,1),9/24,21/24)-MEDIAN(MOD(A1,1),9/24,21/24)

  4. #4
    Registered User
    Join Date
    07-16-2019
    Location
    Lisbon, Portugal
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Count Hours between 2 dates

    Quote Originally Posted by Root_ View Post
    See if the following formula works for you:

    =MAX(0,21/24-MOD(A1,1))+MAX(0,MOD(B1,1)-9/24)+(INT(B1)-INT(A1)-1)/2
    Hello,
    Thank you for your time helping me.
    The formula seem to have a error, on a ).

    Thanks anyway.

  5. #5
    Registered User
    Join Date
    07-16-2019
    Location
    Lisbon, Portugal
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Count Hours between 2 dates

    Quote Originally Posted by Phuocam View Post
    Or try:

    =DATEDIF(A1,B1,"d")/2+MEDIAN(MOD(B1,1),9/24,21/24)-MEDIAN(MOD(A1,1),9/24,21/24)
    Hello,

    First i was having trouble because datedif was not showing, but after some research found that I can still use it.

    Thanks, this solved my issue.

+ 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. count hours betweens 2 dates
    By Framboosje in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-24-2018, 12:22 PM
  2. Count hours between two Dates and times allowing for exceptions.
    By R2C2 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-04-2015, 06:57 AM
  3. [SOLVED] count hours between two dates
    By kbella999 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-16-2014, 10:24 PM
  4. Replies: 12
    Last Post: 07-25-2012, 10:13 PM
  5. Replies: 3
    Last Post: 02-16-2012, 01:51 PM
  6. Replies: 6
    Last Post: 03-25-2010, 07:50 AM
  7. [SOLVED] how do I count a rota with no dates and using 24 hours clock
    By APYDS in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-20-2005, 04:05 PM

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