+ Reply to Thread
Results 1 to 8 of 8

How to convert: (1) 6:00 AM to 0600; and (2) 8:00 PM to 2000?

  1. #1
    Registered User
    Join Date
    03-19-2019
    Location
    San Diego, California
    MS-Off Ver
    2016
    Posts
    5

    How to convert: (1) 6:00 AM to 0600; and (2) 8:00 PM to 2000?

    I have cells in Excel that are formatted as '1:30 PM', and I want to know how to convert: (1) '6:00 AM' to '0600'; and (2) '8:00 PM' to '2000'?

    I've spent a lot of time trying to figure this out, but I don't know how to add a '0' before the 600, nor do I know how to get rid of the colon. Thank you for your help.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: How to convert: (1) 6:00 AM to 0600; and (2) 8:00 PM to 2000?

    =TEXT(HOUR(A1)*100+MINUTE(A1),"0000")

    This will change the value to text 0600

    or change the format of the cell to Custom using hhmm though this will not change the value to 600, only the display.
    600 is 0.25 in Excel time so the value will still be 0.25 not 600.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: How to convert: (1) 6:00 AM to 0600; and (2) 8:00 PM to 2000?

    =text(hour(a1)*100,"0000")

  4. #4
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: How to convert: (1) 6:00 AM to 0600; and (2) 8:00 PM to 2000?

    Quote Originally Posted by Ghozi Alkatiri View Post
    =text(hour(a1)*100,"0000")
    This doesn't work if minutes/seconds are also entered.

  5. #5
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: How to convert: (1) 6:00 AM to 0600; and (2) 8:00 PM to 2000?

    it is difficult to know if the cells are date/times or text
    =TEXT(a1,"HHMM")
    =LEFT(F9,SEARCH(":",F9,1)-1)*100+IF(RIGHT(F9,2)="AM",0,1200)+MID(F9,SEARCH(":",F9,1)+1,2) and custom format cell as 0000

  6. #6
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: How to convert: (1) 6:00 AM to 0600; and (2) 8:00 PM to 2000?

    If D23=6:00 am then

    =TEXT(HOUR(D23),"00")&TEXT(MINUTE(D23),"00")
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  7. #7
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: How to convert: (1) 6:00 AM to 0600; and (2) 8:00 PM to 2000?

    Quote Originally Posted by davsth View Post
    it is difficult to know if the cells are date/times or text
    =TEXT(a1,"HHMM")
    Hi, the above would work for both datetime and datetime stored as text; and is the optimal solution.

  8. #8
    Registered User
    Join Date
    03-19-2019
    Location
    San Diego, California
    MS-Off Ver
    2016
    Posts
    5

    Re: How to convert: (1) 6:00 AM to 0600; and (2) 8:00 PM to 2000?

    Thank you to everyone for helping solve this issue: (1) Special-K; (2) Ghozi Alkatiri; (3) davsth; (4) kvsrinivasamurthy; and (5) XLent. You are all awesome and super knowledgeable. It really means a lot to me and I appreciate the prompt responses.

+ 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] 6.00 to this 0600 please
    By Domenic in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 07:05 AM
  2. 6.00 to this 0600 please
    By Domenic in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 06:05 AM
  3. [SOLVED] 6.00 to this 0600 please
    By Domenic in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 04:05 AM
  4. 6.00 to this 0600 please
    By Steved in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  5. [SOLVED] 6.00 to this 0600 please
    By Steved in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  6. 6.00 to this 0600 please
    By Steved in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  7. [SOLVED] 6.00 to this 0600 please
    By Steved in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  8. [SOLVED] 6.00 to this 0600 please
    By Steved in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-13-2005, 12:05 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