+ Reply to Thread
Results 1 to 4 of 4

How do I convert an integer number to a 24-hour hh:mm time format using existing syntax?

  1. #1
    Registered User
    Join Date
    11-06-2012
    Location
    ndemene
    MS-Off Ver
    Excel 2010
    Posts
    74

    How do I convert an integer number to a 24-hour hh:mm time format using existing syntax?

    How do I convert an integer number to a hh:mm time format using existing VBA Excel syntax? For example, 900 = 09:00 and 2100 = 21:00, 930 = 09:30, 2130 = 21:30. In other words, I don't want AM/PM stuff (I want the 24-hour system).

    Any help in getting the (preferably one-liner) syntax to do this would be greatly appreciated!

  2. #2
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: How do I convert an integer number to a 24-hour hh:mm time format using existing synta

    In vba:
    Please Login or Register  to view this content.
    where stemp holds the original value

    In formula
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-06-2012
    Location
    ndemene
    MS-Off Ver
    Excel 2010
    Posts
    74

    Re: How do I convert an integer number to a 24-hour hh:mm time format using existing synta

    Sorry for the late reply but, could you also tell me how to do the opposite? That is, to convert a 24-hour time to an integer as expressed in my first post.

  4. #4
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: How do I convert an integer number to a 24-hour hh:mm time format using existing synta

    Yes,
    In Excel formula giving text outputwith leading zero
    Please Login or Register  to view this content.
    and if you want a number for efficient math
    Please Login or Register  to view this content.
    See image attachedtimes integers.JPG

    Similarly with VB but VB uses VAL() rather than VALUE()

+ 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