+ Reply to Thread
Results 1 to 8 of 8

Extract hour from TIME in NON-Military time

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2007
    Posts
    2,488

    Extract hour from TIME in NON-Military time

    Hi,

    I am trying to put the time in the file name in this manner. Lets say its 9pm.........

    Then the filename would be something like this

    ABCDEF_9_00_PM

    I know i can get the time from the "Time" command in VBA.

    From this i can extract the hour, min and AM/PM.

    The problem is when i extract the hour it is in military time:

    Please Login or Register  to view this content.
    The above could could produce hours_2Digit = 21

    I want it to be hours_2Digit = 9

    Any ideas?

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    18,068

    Re: Extract hour from TIME in NON-Military time

    something like
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Extract hour from TIME in NON-Military time

    Please Login or Register  to view this content.
    If you are pleased with a member's answer then use the Star icon to rate it.

  4. #4
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2007
    Posts
    2,488

    Re: Extract hour from TIME in NON-Military time

    buran, will yours work if its say 9pm?

  5. #5
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Extract hour from TIME in NON-Military time

    yes. you can check in Immediate window
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2007
    Posts
    2,488

    Re: Extract hour from TIME in NON-Military time

    huh, your right, i wonder why this does not work then

    Please Login or Register  to view this content.
    thanks to both of you.
    Last edited by welchs101; 03-17-2015 at 08:29 AM.

  7. #7
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Extract hour from TIME in NON-Military time

    I think because without AM/PM in the format string it assumes 24 hour format.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    18,068

    Re: Extract hour from TIME in NON-Military time

    Or
    Please Login or Register  to view this content.

+ 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] Covert date/time to military time hour only
    By toontown in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-03-2013, 01:05 PM
  2. Military/24 Hour Time Adding and difference finding
    By Squirrel in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-29-2011, 11:05 PM
  3. Military time range to decimal of hour
    By slopland in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-31-2010, 03:25 AM
  4. [SOLVED] How to I convert standard time to Military or 24 hour format?
    By Nacho in forum Excel General
    Replies: 5
    Last Post: 06-28-2006, 02:20 PM
  5. Rounding military time to nearest tenth of an hour
    By rcterrell in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-24-2005, 10:25 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