If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Store time in format xx:xx-yy:yy

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-24-04, 13:29
digital_storm digital_storm is offline
Registered User
 
Join Date: Dec 2003
Posts: 28
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
Reply With Quote
  #2 (permalink)  
Old 01-24-04, 14:39
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-24-04, 14:40
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,732
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"
Reply With Quote
  #4 (permalink)  
Old 01-24-04, 18:02
digital_storm digital_storm is offline
Registered User
 
Join Date: Dec 2003
Posts: 28
Ok, thank you!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On