Need your help please. Covert time to army time, and trim off the date & am/pm

Discussion in 'ASP .Net' started by jonny, Oct 10, 2007.

  1. jonny

    jonny Guest

    Option Explicit
    Private mdTarget1 As Date
    Private mdTarget2 As Date

    ' called on form load
    Public Sub SetRecordStartTime()

    mdTarget1 = DateAdd("n", 60, Time)
    mdTarget2 = DateAdd("n", 120, Time)

    End Sub

    ' I am using then using a if statement like "If Time > mdTarget1 And
    Time < mdTarget2 Then"


    Everything is working until after 12 midnight and then it returns for
    example something like "10/10/07 12:00:00 AM" .

    Can you help me do the following:

    1st: Covert time to army time (1-24);
    2nd: Only show the time and not the date or am/pm;


    Your help would be greatly appreciated!!!
     
    jonny, Oct 10, 2007
    #1
    1. Advertising

  2. If you need to format your time in 24 hour formatting, use the formatting
    string HH.mm.

    firstTargetDate = DateAdd("n", 60, Time)
    secondTargetDate = DateAdd("n", 2550, Time)

    Dim test As String
    test = secondTargetDate.ToString("HH.mm")

    The test variable then equals "04.16" which is 2550 minutes from when I coded
    it, but yes, it does take the new day into consideration and prepend that
    to the front. Just as long as you realize it's the next date, you can cut
    the date part off with custom ToStrings. You don't want to totally get rid
    of the date component (behind the scenes, presentation is another case) because
    it is needed for proper calculation--you don't want 2100-0300 span to the
    next day.

    HTH.

    -dl

    --
    David R. Longnecker
    http://blog.tiredstudent.com

    > Option Explicit
    > Private mdTarget1 As Date
    > Private mdTarget2 As Date
    > ' called on form load
    > Public Sub SetRecordStartTime()
    > mdTarget1 = DateAdd("n", 60, Time)
    > mdTarget2 = DateAdd("n", 120, Time)
    > End Sub
    >
    > ' I am using then using a if statement like "If Time > mdTarget1 And
    > Time < mdTarget2 Then"
    >
    > Everything is working until after 12 midnight and then it returns for
    > example something like "10/10/07 12:00:00 AM" .
    >
    > Can you help me do the following:
    >
    > 1st: Covert time to army time (1-24);
    > 2nd: Only show the time and not the date or am/pm;
    > Your help would be greatly appreciated!!!
    >
     
    David R. Longnecker, Oct 10, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Summu82
    Replies:
    5
    Views:
    904
    Richard Heathfield
    Jun 7, 2006
  2. Replies:
    0
    Views:
    443
  3. FAQ server
    Replies:
    0
    Views:
    177
    FAQ server
    Aug 29, 2006
  4. FAQ server
    Replies:
    0
    Views:
    165
    FAQ server
    Oct 26, 2006
  5. FAQ server
    Replies:
    6
    Views:
    256
    Jonas Raoni
    Dec 25, 2006
Loading...

Share This Page