Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2012
    Posts
    126

    Unanswered: Need help converting text to time

    Hey guys, im pulling data from our 400 and it stores time as follows:

    12:00:00am shows up as 0
    12:01:01am shows up as 1
    4:00:00pm shows up as 160000
    etc.

    I was going to use the mid left right functions but how would i handle midnight being just 0?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so it looks like its HHMMSS
    If it were me Id probably use a function to retun the time as a datetime value

    public function MakeTime(value as integer) as datetime
    'set up our default return value
    Maketime = cdate(format(value,"00:00:00"))
    end function

    assuming the code above works (and Ive not tested it soo I don't know it works) then you coudl just use the format fucntion directly
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Aug 2012
    Posts
    126
    Quote Originally Posted by healdem View Post
    so it looks like its HHMMSS
    If it were me Id probably use a function to retun the time as a datetime value

    public function MakeTime(value as integer) as datetime
    'set up our default return value
    Maketime = cdate(format(value,"00:00:00"))
    end function

    assuming the code above works (and Ive not tested it soo I don't know it works) then you coudl just use the format fucntion directly
    Wow, thats a great idea. Question though, what would i use as the format function in the query? If my field is say [StartTime] how would the function be laid out?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    cdate(format(avalue,"00:00:00"))
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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