+ Reply to Thread
Results 1 to 7 of 7

Time format not working as expected

  1. #1
    Registered User
    Join Date
    08-22-2011
    Location
    Ireland
    MS-Off Ver
    Excel 365
    Posts
    11

    Time format not working as expected

    Hi All, Happy New Year.
    It's been a long time since I was here. Glad your still here.
    I have a sheet (sample attached) where two columns C & P are formatted as time hh:mm AM/PM
    I want column Q to calculate the time difference between these two columns.
    Q is formatted to give hrs and mins
    I used the simple formula =C2-P2 but I'm getting the #Value! error.
    Also where all the cells a formatted the same the typed results are different.
    Typing the time in the cells in the same manner gives different results in different cells
    I'm sure its something small I'm doing wrong so I'm hoping you can help.
    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,466

    Re: Time format not working as expected

    The values in column C are not proper values of time - they are text values which just look like a time (hint am should show as AM). So, when you try to carry out some arithmetic using these values then you get an error message. All of the values in column P (except for P2) are text values as well. P2 shows 7:12 AM, but if you select that cell and look in the formula bar you will see 08/01/1900 07:12:00, so it is clearly only showing the time part of a date and time value.

    Where did the data come from? It is important to rectify these variations as early as possible - hopefully at the source.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    08-22-2011
    Location
    Ireland
    MS-Off Ver
    Excel 365
    Posts
    11

    Re: Time format not working as expected

    Hi Pete,
    Thank you for your insight.
    These are manually entered info.
    What I'm trying to do is get the cells in columns C & P to operate as time columns so I can show the time difference between them.
    Both are formatted (on my sheet) as custom hh:mm am/pm and what I've dicovered is when I thought the some cells was recognising a time value it was simply predicting/copying what was entered in other cells.
    So what can I do to get the result I'd like.

    Regards

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,466

    Re: Time format not working as expected

    You should enter times with colons between the hours, minutes and seconds parts, like this:

    7:12:0

    for 12 minutes past 7, and Excel will then interpret that as a time. If you do not have any hours you should use a zero, like 0:2:30 for 2 minutes and 30 seconds, otherwise Excel will take the minutes and seconds as hours and minutes.

    You can apply whatever format you wish to those values.

    Hope this helps.

    Pete

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,919

    Re: Time format not working as expected

    Get rid of the customised format. Format cells as TIME and enter time values like this:

    10:00
    7:20
    13:45
    etc.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    02-27-2025
    Location
    Alabama
    MS-Off Ver
    Office 16
    Posts
    10

    Re: Time format not working as expected

    I believe I may be able to help with this. I am working on creating a sheet that will take entered clock in time and entered clock out time and give the difference in minutes. My clock in time column and my clock out time column are both formatted as TIME, and I chose 1:30 PM and the next column that shows the difference is formatted as CUSTOM and I chose Custom h:mm. Then my difference formula is =B2-A2 - Just replace my columns for yours. Make sure you are putting a space before the AM or PM. I haven't quite figured out how not to have to do that just yet. But I'm looking. Also, I know this may be really simple for some, but I was getting an error simply because my answer column wasn't wide enough. So, once I stretched out my little excel box to make it wider, the answer was showing correctly. I hope this helps. I'm new here and just learning excel. Wish me luck

  7. #7
    Registered User
    Join Date
    03-07-2024
    Location
    Virginia
    MS-Off Ver
    Office 365
    Posts
    1

    Re: Time format not working as expected

    candidawalker75 - in regards to your comment about putting a space before the AM or PM, just a thought if you are open to using 24 hour time: set up your time display as time type 1:30 PM. Input 17:37 and it will display as 5:37 PM.

+ 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] VBA to format header not working as expected
    By robbo1172 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-18-2020, 04:21 AM
  2. conditional format query not working as expected
    By max8719 in forum Excel General
    Replies: 4
    Last Post: 12-16-2018, 11:24 AM
  3. Expected table is not in the expected format - ADODB Connection to Read Only Excel file
    By Roshan10043 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2018, 10:54 AM
  4. Date format not working as expected when extract from text string
    By iantix in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-17-2017, 12:37 PM
  5. [SOLVED] Conditional Format not working as expected
    By scudo in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-10-2015, 10:44 AM
  6. [SOLVED] FORMAT not working for Date to text as expected
    By JimSnyder in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2013, 05:30 PM
  7. Excel VBA-Date format "mmm" not working as expected
    By sbishops in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-23-2009, 06:39 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