Consulting

Results 1 to 7 of 7

Thread: Converting military times to numbers

  1. #1
    VBAX Regular
    Joined
    Apr 2006
    Posts
    12
    Location

    Converting military times to numbers

    I have a column that contains times in military format. I want to convert the times to numbers, with no formatting.

    For example:

    Right now the columns show the following:

    0:01
    0:23
    2:14
    13:32
    19:54

    Their actual values are:

    12:01:00 AM
    12:23:00 AM
    2:14:00 AM
    1:32:00 PM
    7:54:00 PM

    I want it to instead have the following values:

    1
    23
    214
    1332
    1954

    They should be formatted as numbers, with no indication that they represent times.

    Is this possible?

    I have a worksheet that contains military times in number format that I need to compare against.

    Thanks.

  2. #2
    VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Assuming your time is in cell A1,

    =VALUE(HOUR(A1)&(B1*60*24)-(HOUR(A1)*60))

  3. #3
    geekgirlau,
    B1 should be A1 on your formula.
    It works perfectly.

    this also worked for me. Assuming A1 has the time:

    =CONCATENATE(HOUR(A1),MINUTE(A1))

    But i get a 01 instead of 1.

    Last edited by Chente28; 04-05-2006 at 11:16 PM. Reason: Correcting

  4. #4
    VBAX Contributor
    Joined
    Jul 2005
    Posts
    169
    Location
    =--CONCATENATE(HOUR(A1),MINUTE(A1))
    will convert the text value to number...

  5. #5
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Just answered this on Tek-Tips - there's a FAQ somewhere on cross-posting but off the top of my head I don't where it is - basically, it's not actaully wrong but it's good manners, to say the least, to state that you are doing it.

    I don't think any of the answers here are correct but I think this will do it:

    =VALUE(TEXT(A1,"HHMM"))
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  6. #6
    VBAX Regular
    Joined
    Apr 2006
    Posts
    12
    Location
    Sorry TonyJollans. I wasn't aware of the cross-posting etiquette, but it definitely makes sense. I'll be sure to state that I am doing so in the future. I was panicking because I need to have something done for work tomorrow and I just couldn't figure this little part out.

    Thanks.

  7. #7
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    No problem.

    And Welcome to VBAX!
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •