Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store time of the day in SQL

How would you store a time or time range in SQL? It won't be a datetime because it will just be let's say 4:30PM (not, January 3rd, 4:30pm). Those would be weekly, or daily meetings. The type of queries that I need are of course be for display, but also later will include complex queries such as avoiding conflicts in schedule. I'd rather pick the best datatype for that now.

I'm using MS SQL Server Express 2005.

Thanks!

Nathan

like image 723
Nathan H Avatar asked May 01 '09 18:05

Nathan H


People also ask

Is there a time field in SQL?

SQL Server accepts time values in the following formats: 14:30, 14:30:20, 14:30:20:145943, 2 PM, 2:30 PM, 2:30:20 PM 2:30:20.145943 PM.


1 Answers

Personally I would find this a reason to upgrade to 2008 which has a separate time datatype.

like image 62
HLGEM Avatar answered Sep 24 '22 08:09

HLGEM