+ Reply to Thread
Results 1 to 6 of 6

Time Conversion Equation

  1. #1
    Forum Contributor
    Join Date
    11-23-2013
    Location
    La Crosse, Wi
    MS-Off Ver
    Excel 2010
    Posts
    113

    Time Conversion Equation

    I have a long length of times that are formatted XXXX AM or XXXX PM. I need to convert these into military time so I can do a search on them. I tried to format them, but since there is no colon in the time it does not convert. Can anyone help me with this?

    Thanks in advance!
    Jeff B
    Last edited by boynejs; 11-15-2021 at 12:44 PM.

  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,009

    Re: Time Question

    Try

    =IF(RIGHT(A1,2)="AM",TIME(LEFT(A1,2),--MID(A1,3,2),0),TIME(LEFT(A1,2)+12,--MID(A1,3,2),0))

    format cell as hh: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
    Forum Contributor
    Join Date
    11-23-2013
    Location
    La Crosse, Wi
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Time Question

    I am still having issues with this. I tried the suggested formula...

    =IF(RIGHT(A1,2)="AM",TIME(LEFT(A1,2),--MID(A1,3,2),0),TIME(LEFT(A1,2)+12,--MID(A1,3,2),0))

    and the times are not correct. Here is an attached spreadsheet of what I am getting. The more I think about it, I would be fine with it just giving me a time in AM or PM.

    Jeff B
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    07-13-2021
    Location
    California, USA
    MS-Off Ver
    2010
    Posts
    513

    Re: Still Having Issue with a Time Conversion Equation

    Try:

    =TEXT(LEFT(A2,4),"00\:00 \a\m") + IF(RIGHT(A2,2)="pm",0.5)

    Caveat: I assume that midnight is input as either "1200 am" or "000 am", not "2400 pm".
    Last edited by curiouscat408; 11-15-2021 at 11:36 AM.

  5. #5
    Forum Contributor
    Join Date
    11-23-2013
    Location
    La Crosse, Wi
    MS-Off Ver
    Excel 2010
    Posts
    113

    Solved: Still Having Issue with a Time Conversion Equation

    That worked. Thanks

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2412
    Posts
    13,613

    Re: Time Conversion Equation

    I'm late to the party again, but here's another way.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Now convert.

    Edit: Actually this is simpler than my last.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 11-15-2021 at 08:00 PM.
    Dave

+ 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. Time question
    By Ducky405 in forum Excel General
    Replies: 4
    Last Post: 12-07-2015, 04:23 PM
  2. Time Question
    By timtrag12 in forum Excel General
    Replies: 2
    Last Post: 10-19-2011, 11:15 PM
  3. time question
    By sedonovan in forum Excel General
    Replies: 4
    Last Post: 06-26-2006, 01:10 PM
  4. [SOLVED] Time Question
    By colin in forum Excel General
    Replies: 1
    Last Post: 03-17-2006, 08:45 AM
  5. [SOLVED] Time Question
    By SU in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-01-2005, 08:05 AM
  6. Time question
    By Stuart in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-29-2005, 03:06 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