Results 1 to 8 of 8

Thread: vbShortTime returns LongTime...

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    4

    vbShortTime returns LongTime...

    Hi all,

    I am trying to return a 24 hour format using either FormatDateTime or Format.

    However when this line executes:

    sTime = FormatDateTime(Time, vbShortTime)

    It returns the same long 12 hour value with AM/PM as does this:

    sTime = FormatDateTime(Time, vbLongTime)

    ----------------

    Any ideas?

    Thanks,

    Jim

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: vbShortTime returns LongTime...

    format("14:22:22","h.m.s")

    or hh:mm:ss
    Last edited by dglienna; Feb 2nd, 2005 at 03:07 AM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    4

    Re: vbShortTime returns LongTime...

    Thanks, but using the syntax:

    sTime = Format(Time, "h.m.s")

    sTime is still passed the 12 hour AM/PM format.

    When the simple stuff doesn't work it makes my head spin...

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: vbShortTime returns LongTime...

    MsgBox Format(TimeSerial(14, 2, 2), "hh:mm:ss")

    returns 14:02:02 for me


    if I add AMPM it makes it 12 hour format

  5. #5
    Addicted Member
    Join Date
    Aug 2004
    Posts
    176

    Re: vbShortTime returns LongTime...

    Quote Originally Posted by Trondyne

    sTime = Format(Time, "h.m.s")

    sTime is still passed the 12 hour AM/PM format.
    works fine for me. doesn't give AM/PM.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    4

    Re: vbShortTime returns LongTime...

    Sadly, it isn't working for me. The question is why?

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    4

    Re: vbShortTime returns LongTime...

    Changed:

    Dim sTime As Date

    to

    Dim sTime

    And this seems to solve the format problem.. Not sure why though.

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: vbShortTime returns LongTime...

    Oh. You didn't say that. I thought it was a string (cause of the sDate)

Posting Permissions

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



Click Here to Expand Forum to Full Width