+ Reply to Thread
Results 1 to 4 of 4

Converting hours into days, hours & minutes

  1. #1
    Registered User
    Join Date
    10-07-2009
    Location
    Lancashire, UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Unhappy Converting hours into days, hours & minutes

    Hi

    I have a problem that I hope you can help with.

    For my work, I get paid in 'time in lieu' re: airline flight times for all time over 7.5 hours. These times are input in 24 hour format and can go 'past' midnight - into the next day. I need to know in days, hours & minutes, how much lieu time I have got.

    Therefore in
    A1 = start time flight out
    B1 = end time flight out
    A2 = start time flight back
    B2 = end time flight back
    C2 = total time =sum(B1-A1)+(B2-A2)-7.5 hours
    D2 = d "days" h "hours" m "minutes"

    My problem is two fold:
    1. getting times 'past' midnight to add-up
    2. getting answer in D2 to relate to 'actual' times and not decimal times

    I know I am nearly there - but so far....

    I have tried using:

    =DAY(D2*3)&" days "&(D2*3-DAY(D2*3))*8&" hours "&MINUTE(D2)&" minutes"

    But this is based on an 8 hour day - not 7.5 hours
    I have tried converting times into decimals and formatting cells as [h]:mm, for 24 hour clock.

    Hope all this makes sense and that you can help me

    Regards
    John

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Converting hours into days, hours & minutes

    Assuming all times are in the same time zone (e.g., Zulu), then

    = B1 - A1 + (A1>B1) + B2 - A2 + (A2>B2) - "7:30"

    Then you can format that as d h:mm
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    10-07-2009
    Location
    Lancashire, UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Talking Re: Converting hours into days, hours & minutes

    Hi Shg

    Many thanks for such a quick reply.
    It works - thank you!

    I have attached a sample .xls
    May I ask from my example, can you explain (B2>C2) part of the calculation - that returns False and (B10>C10) which returns True?

    I am just interested in the use of that part of the calculation, as to return the correct answer.

    Because in my example.xls B10 = 23:45 and C10 = 16:30 (ie a long haul flight over 2 separate days) = true

    Whilst in the over example the answer is false - but the answer is still correct?

    Many thanks

    John
    Attached Files Attached Files

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Converting hours into days, hours & minutes

    The expression A1>B1 returns either true or false.

    Being involved in an arithmetic expression [= B1 - A1 + (A1>B1)], Excel coerces it to 1 (if true) or 0 (if false).

    So if you leave at 11PM and arrive at 1AM, 1AM - 11PM is -22 hours, plus one (day) = +2 hours.

    The reason for the parens is due to precedence of operators (see Help for About calculation operators); they force Excel excel to evaluate what's inside the parens first. Otherwise, the expression wiould evaluate as

    =(B1 - A1 + A1) > B1

    ... and just return true or false.

+ 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