+ Reply to Thread
Results 1 to 18 of 18

Hour Computation

  1. #1
    Registered User
    Join Date
    12-16-2022
    Location
    Cebu
    MS-Off Ver
    WPS Kingston
    Posts
    38

    Hour Computation

    Hi guys, I'd like to do an hour computation like from 21:00 till 7:00 the following day

    I've tried =TEXT(C4-C5,"h:mm") but instead of 10 hours I'm getting 14 hours. I've tried switching to am/pm but same result and if I switch c5 and c4 I get a value error....

    Any ideas what I'm doing wrong or perhaps another formula that works.

    Thanks in advance
    Attached Files Attached Files

  2. #2
    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
    30,871

    Re: Hour Computation

    Try

    =TEXT(C5-C4+IF(C5<C4,1,0),"h:mm")
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Registered User
    Join Date
    12-16-2022
    Location
    Cebu
    MS-Off Ver
    WPS Kingston
    Posts
    38

    Re: Hour Computation

    Thanks John that works so far but only if C4 and C5 have data. If only one field is filled it gives incorrect hours

    If only C4 is filled it counts the hours till midnight
    If only C5 is filled it starts counting from midnight

    Is there a possibility to get a value error otherwise the total hours could be incorrect. Also easier to see if I missed sth

  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
    30,871

    Re: Hour Computation

    Try

    =IF(AND(C4<>"",C5<>""),TEXT(C5-C4+IF(C5<C4,1,0),"h:mm"),"")

  5. #5
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,418

    Re: Hour Computation

    Formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and time format
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    12-16-2022
    Location
    Cebu
    MS-Off Ver
    WPS Kingston
    Posts
    38

    Re: Hour Computation

    Quote Originally Posted by JohnTopley View Post
    Try

    =IF(AND(C4<>"",C5<>""),TEXT(C5-C4+IF(C5<C4,1,0),"h:mm"),"")
    Works great....it's a bit far fetched perhaps but is there a possibility to determine the hours between 22:00 and 6:00.

    Like if someone starts at 20:00 and finishes at 4:00, that only 6 hours would show in C7 compared to the 8 hours in C6
    Last edited by El-Fidel; 02-21-2023 at 11:21 AM. Reason: Forgot Quote

  7. #7
    Registered User
    Join Date
    12-16-2022
    Location
    Cebu
    MS-Off Ver
    WPS Kingston
    Posts
    38

    Re: Hour Computation

    Quote Originally Posted by Czeslaw View Post
    Formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and time format
    Unfortunately didn't do the trick but John already gave me a good solution that solved the issue. Thanks for trying
    Last edited by El-Fidel; 02-21-2023 at 11:22 AM. Reason: Forgot Quote

  8. #8
    Registered User
    Join Date
    12-16-2022
    Location
    Cebu
    MS-Off Ver
    WPS Kingston
    Posts
    38

    Re: Hour Computation

    Hi guys, thought everything works so far and highlighted the days without work or faulty entries but when I summed it all up it only shows 0 value

    Changed the format to h:mm,@ as suggested on various pages but no luck
    Attached Files Attached Files

  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
    30,871

    Re: Hour Computation

    Results formmated as TEXT: changed to format as time .

    =IF(AND(C4<>"",C5<>""),(C5-C4+IF(C5<C4,1,0)),"")

    format as [h]:mm

    See attached
    Attached Files Attached Files
    Last edited by JohnTopley; 02-22-2023 at 08:54 AM.

  10. #10
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,663

    Re: Hour Computation

    Please Login or Register  to view this content.
    Or this alternitive.
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  11. #11
    Registered User
    Join Date
    12-16-2022
    Location
    Cebu
    MS-Off Ver
    WPS Kingston
    Posts
    38

    Re: Hour Computation

    Quote Originally Posted by JohnTopley View Post
    Results formmated as TEXT: changed to format as time .

    =IF(AND(C4<>"",C5<>""),(C5-C4+IF(C5<C4,1,0)),"")

    format as h:mm

    See attached
    I've tried all different formats in between hoping sth would work but had h:mm in between as well....

    It gives a summary but my total is incorrect. It shows 16 hours only instead of 40

    Unfortunately also my cell rules don't work anymore with the new formula....
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    12-16-2022
    Location
    Cebu
    MS-Off Ver
    WPS Kingston
    Posts
    38

    Re: Hour Computation

    Quote Originally Posted by popipipo View Post
    Please Login or Register  to view this content.
    Or this alternitive.
    Thanks Popipipo but unfortunately the same problems....total doesn't add up for whatever reason and also my conditional formatting doesn't seem to work anymore...
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,663

    Re: Hour Computation

    Take a look at this.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    12-16-2022
    Location
    Cebu
    MS-Off Ver
    WPS Kingston
    Posts
    38

    Re: Hour Computation

    Awesome that works, thanks a lot _/\_

    Any ideas why my conditional formatting doesn't work highlight the cells a before? In one of my previous files it worked with cell value less than =",01" to be marked as red. Tried also zero value but same outcome. I would like to showcase days without work as well as when there are faulty entries like only starting or end time

    May have to change the value to a bit lower as I've seen with a different format that 8 hours is only 0.3333 of a day but just doesn't work in general anymore

  15. #15
    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
    30,871

    Re: Hour Computation

    Removed by JT

  16. #16
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,663

    Re: Hour Computation

    In excel 1 day (24 h) counts as 1
    1 hour =1/24
    2 hour =2/24
    ..
    ..
    8 hour = 8/24 and that is a little more as 0.3333

  17. #17
    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
    30,871

    Re: Hour Computation

    Formatting of cell is wrong >> :[h]:mm

  18. #18
    Registered User
    Join Date
    12-16-2022
    Location
    Cebu
    MS-Off Ver
    WPS Kingston
    Posts
    38

    Re: Hour Computation

    The formatting seems to be correct now since the hours and the total appear correct, yet my conditional formatting still fails.

    Have two conditional formatting as per screenshot but neither of it works....
    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. Missing one hour in Work rest Hour for Seafarers
    By ljumljum in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-22-2021, 09:45 AM
  2. Headcount Rota By Hour - 24 Hour Shifts (Countif problems)
    By riosuk in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-06-2021, 04:52 PM
  3. [SOLVED] Calculating Each Hour Worked by Multiple Employees to get the total Cost of Each Hour
    By cs25001 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-06-2019, 06:55 AM
  4. Replies: 1
    Last Post: 12-19-2017, 10:46 AM
  5. Replies: 4
    Last Post: 10-02-2015, 10:00 AM
  6. Replies: 0
    Last Post: 03-07-2014, 11:26 AM
  7. [SOLVED] convert decimal numbers to a fraction of an hour for payroll hour
    By Flower in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-10-2006, 03:50 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