Results 1 to 5 of 5

Thread: storing time

  1. #1
    Join Date
    Apr 2003
    Posts
    176

    Unanswered: storing time

    how can i store time in my table

    1 hr:55 mins:22 secs

  2. #2
    Join Date
    Apr 2003
    Posts
    176
    This is my tot requirement.

    I have two columns with time data types.
    First column is is target_time and secong column is the time_reached

    target_time time reached delay

    3:23:12 4:13:12 1:40:00
    2:23:23 3:42:24 1:19:01

    (h:mi:ss) (h:mi:ss) (h:mi:ss)
    formual is : (time_reached-target_time)=delay

    Thanks.

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Create a table something like:
    Code:
    CREATE TABLE foo (
       target_time DATETIME NULL
    ,  time_reached DATETIME NULL
       )
    
    INSERT INTO foo
       SELECT '3:23:12', '4:13:12'
    ,  UNION ALL SELECT '2:23:23', '3:42:24'
    
    SELECT target_time, time_reached
    ,  DateAdd(seconds, DateDiff(seconds, time_reached, target_time)
    ,     '0:00') AS delay
       FROM foo
    Beware, you are only storing time values. This will cause havok if you ever roll past midnight!

    -PatP

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Cry havoc and let slip the databases of war!

    I have to wonder why you only want to store time values, and not the date portion.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  5. #5
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Sounds like it may be marathon run times, or something. Anyway, it would be an interesting application of datetime.

Posting Permissions

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