Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    28

    Unanswered: Store time in format xx:xx-yy:yy

    Hello!

    Is there a way to store a time like: 8:00-9:00
    or do I have to store 2 "hours" like 8:00 (hour 1) and 9:00 (hour2) in my row "starthour" and "endhour"

    I want in an easy way to be able to compare booked hours so I would really like to have time in a format like xx:xx-yy:yy

    Thanks for helping me // D_S

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the only way to store both times in one field is as a string

    if you want to do range checking, yes, use two TIME fields

    if the booked hours can ever span more than one day, use two DATETIME fields
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You can store it as a character string, but you can't store it as a single datetime value. Either store the StartTime and the EndTime, or the StartTime and the Duration.
    If it's not practically useful, then it's practically useless.

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

  4. #4
    Join Date
    Dec 2003
    Posts
    28
    Ok, thank you!

Posting Permissions

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