Results 1 to 6 of 6

Thread: DateTime problem???

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    32

    Unhappy

    This is a SQL problem but here it goes...

    Does anyone know how to extract the time from a datetime datatype?

  2. #2
    Lively Member Skateboarder's Avatar
    Join Date
    Nov 2000
    Location
    Delfzijl, the Netherlands
    Posts
    66

    what do you mean

    What exactly do you mean?
    To VB or not to VB, that's the question...

  3. #3
    Lively Member
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    96
    as far as I know the datetime field store the date and time in a standard format

    e.g. dd/mm/yyyy hh.mm.ss (just an example...I think!)

    to get just the time try something along the lines of..

    left( variablename, 11)

    This will then move 11 chars in and display the rest, which in my example is hh.mm.ss.

    You'll need to be sure of the format first and probably need to do some trial and error on it.

    You can also use right( variablename, starting point) it that is any easier.

    H.
    Just trying to muddle through...

  4. #4
    Lively Member Skateboarder's Avatar
    Join Date
    Nov 2000
    Location
    Delfzijl, the Netherlands
    Posts
    66

    Easier

    If all you want to have is the time as hh.mm.ss format, just use the following:
    Code:
    Dim MyTime As String
    MyTime = Format(Time, "Long Time")
    And here you go, u don't have to extract and u got the time stored as MyTime!
    To VB or not to VB, that's the question...

  5. #5
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    400
    The date part is to the left of the decimal, and the time part is to the right.

    You can use Int(dtmVariable) to strip out the time. Probably, you can use dtmVariable - Int(dtmVariable) to strip out the date.

    Or, you can use the DatePart function.

  6. #6
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    There is actually a function in VB6:
    TimeValue(<date>)

    If you place your variable in here you'll get what you want:
    Code:
        MyTime = TimeValue(SQLDateTimeVar)
    Hope this helps.
    -Excalibur

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