+ Reply to Thread
Results 1 to 7 of 7

Military time pass midnight trouble

  1. #1
    Registered User
    Join Date
    11-14-2013
    Location
    Hawaii
    MS-Off Ver
    Excel 2013
    Posts
    3

    Military time pass midnight trouble

    Hello I have been stuck trying to figure out how to fix this problem. Im doing a timesheet for my workplace and my boss likes to do it in military time.

    I made a monthly calender showing hours worked in one cell then total hours in another for that shift.

    for example:

    A1: 1200-2200

    B1: 10

    using this formula =IF(A1="","",24*(TEXT(RIGHT(A1,4),"00\:00")-TEXT(LEFT(A1,4),"00\:00")))

    This formula works till it runs into the next day. Anything pass 0000 and my numbers are wrong

    for example:

    A1: 2200-0800

    B1:-14

    I tried to add ABS on the previous formula but all it does is remove the negative

    Is there any work around this?

    I do want to emphasize that I want to keep the shift time in 1 column only Im trying to avoid separating the start and end time into their own column.

    Is 1 column possible to fix or do I have to separate them. Please any help is much appreciated

    TYI

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Military time pass midnight trouble

    welcome to the forum, Jolibee. try:
    =IF(A1="","",24*(MOD(TEXT(RIGHT(A1,4),"00\:00")-TEXT(LEFT(A1,4),"00\:00"),1)))

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Military time pass midnight trouble

    You could add 24 to negative values, which would give you 10 in you example which seems correct
    Ie:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    A better way would be to have shift start time and shift end time in different cells, use the whole date/time as the value, and format the cells to only show the times,
    then you could simply subtract start from end, with the cell the formula is in formatted as [h]:mm
    this works so well because of the way excel stores dates and times, dte is stored to the left of the decimal point (the "integer" part of the date/time) and time is stored to the right (the "decimal" portion) so 12 hours works out to 0.5 for example)
    so as an example :
    A1= start date/time (formatted as time, 24:00)
    B1= end date/time (formatted as time, 24:00)
    C1= B1-A1 (formatted as [h]:mm)

    Hope this helps
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Military time pass midnight trouble

    Quote Originally Posted by Jollibee View Post
    Hello I have been stuck trying to figure out how to fix this problem. Im doing a timesheet for my workplace and my boss likes to do it in military time.



    I do want to emphasize that I want to keep the shift time in 1 column only Im trying to avoid separating the start and end time into their own column.


    TYI
    Why a single column? You are creating all sorts of unnecessary difficulties for yourself and if you want to use times in other formulae or perhaps pivot tables then you are dead in the water.

    Always keep start/finish times in separate columns. It just makes sense and keeps things simple.

    So for example if A1 contains 22:00, and B1 08:00, your formula in C1 would be
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    11-14-2013
    Location
    Hawaii
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Military time pass midnight trouble

    Quote Originally Posted by benishiryo View Post
    welcome to the forum, Jolibee. try:
    =IF(A1="","",24*(MOD(TEXT(RIGHT(A1,4),"00\:00")-TEXT(LEFT(A1,4),"00\:00"),1)))
    Yes thank you for this formula it works great. I was trying to use MOD, but could not figure where in the formula it would go.

  6. #6
    Registered User
    Join Date
    11-14-2013
    Location
    Hawaii
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Military time pass midnight trouble

    Quote Originally Posted by Richard Buttrey View Post
    Why a single column? You are creating all sorts of unnecessary difficulties for yourself and if you want to use times in other formulae or perhaps pivot tables then you are dead in the water.

    Always keep start/finish times in separate columns. It just makes sense and keeps things simple.

    So for example if A1 contains 22:00, and B1 08:00, your formula in C1 would be
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I made a separate column one but my boss did not like it. He wanted to put a full calendar month in one page with employee name, shift, and total hours. So he wanted all that info in each calendar day box without scalling it too small.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Military time pass midnight trouble

    Quote Originally Posted by Jollibee View Post
    I made a separate column one but my boss did not like it. He wanted to put a full calendar month in one page with employee name, shift, and total hours. So he wanted all that info in each calendar day box without scalling it too small.
    Hi,

    Do two columns with 12:00 & 22:00 in each really take up that much more room than a single column with 1200-2200? There is after all only character more.

    But if that's what your boss wants then he of course knows best

    I just know you're adding complexity when it isn't necessary.

+ 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] Military Time Not Calculating after Midnight.
    By heresteve2 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-04-2013, 06:34 PM
  2. [SOLVED] Calculatuing Night Differential from start and end times that pass midnight
    By D J in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-16-2013, 11:35 AM
  3. [SOLVED] Adding date when times pass midnight
    By dvs in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-04-2013, 08:00 AM
  4. [SOLVED] Figuring total hours in military time going passed midnight.
    By NETSPY in forum Excel General
    Replies: 9
    Last Post: 07-09-2012, 05:59 PM
  5. Excel time sheet trouble after midnight
    By ChadE76 in forum Excel General
    Replies: 3
    Last Post: 03-23-2008, 08:41 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