+ Reply to Thread
Results 1 to 4 of 4

How to format times between 12:00 am to 12:59 am (Updated)

  1. #1
    Registered User
    Join Date
    10-24-2012
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    11

    How to format times between 12:00 am to 12:59 am (Updated)

    The attached file is a sample of a timesheet I’m working on. If I enter military time in cell between E4 to N4 and from E9 to N9, it is automatically converted to hh:mm format. For instance 1300 becomes 1:00 PM.

    However, when I enter a time between 12:00 AM to 12:59 AM in a cell, the value inside the cell changes from "hh:mm:ss AM" to "1/1/1900 hh:mm:ss AM".

    For instance 2400 become "1/1/1900 12:00:00 AM" instead of 12:00:00AM inside the cell. Because of this change, I get a ########## error instead of the number of hours between two times as shown in cells G10 and M10.

    Is there a way to get around this problem? Thanks in advance for any suggestions.
    Attached Files Attached Files
    Last edited by smonzon; 01-26-2013 at 03:40 AM. Reason: Wrong Attachment

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,620

    Re: How to format times between 12:00 am to 12:59 am (midnight)

    In military time, the day starts at 00:00 hrs not 12:00 AM. Notice that you have 12 AM after 11 AM! --> The hour after 11 AM is 12 PM or 12:00 military. Then you have 12 pm (noon) after 11 pm...
    Ben Van Johnson

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: How to format times between 12:00 am to 12:59 am (midnight)

    Keep in mind that excel treats time as fractions of 1 day...starting at 0:00 (midnight) and working through to 23:59 (1 minute before midnight). In other words 24 hrs (1 day) = 1, 12 hours = 0.5 or a day, 4 hours = .25 of a day etc etc.

    to test this, enter any time into a cell - it should automatically be reflected/formatted as time. then format that cell as a number, you will see that the time is now a decimal value. Formatting just changes the way the contents of a cell looks, it does not change the actual contents - working with time is a little different in that, when formatted as time, it actually looks like the cell contents have changed, but if you format back to a number, the decimal is still there.

    Hope that helped a bit?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    10-24-2012
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: How to format times between 12:00 am to 12:59 am (Updated)

    Thanks for the information protonLeah and FDibbins, but I've just realized that I attached the wrong file. I have uploaded the correct one this time. On the other hand, I was able to solve the problem by using the MOD function. For instance, typing =MOD(H9-G9,1) in cell G10 provides the correct value. You are correct FDibbins, working with time in Excel is a little more complex. Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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