Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sqlqueries
Starting Member
4 Posts |
Posted - 2015-05-01 : 18:39:52
|
I have a requirement to store time exactly as HH:mm format in sql table. What should be the column data type? How can I store time in this format.I have two text boxes - Start Time and End Time.If i enter 6 and 45, time should be stored as 6:45 ( 24 hours format)If i enter 18 and 45, time should be stored as 18:45 ( 24 hours format)How can I achieve this? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-05-01 : 18:41:24
|
I'd use char data type, but I'd question the requirement.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
sqlqueries
Starting Member
4 Posts |
Posted - 2015-05-01 : 18:49:41
|
Certain features of a web application have to blocked and should be allowed in specific time alone. hence this requirement. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-05-01 : 18:54:00
|
quote: Originally posted by sqlqueries Certain features of a web application have to blocked and should be allowed in specific time alone. hence this requirement.
But the requirement shouldn't specify HOW it is stored. You should be using time data type and have the application transform it if needed. Times should be stored as TIME.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
sqlqueries
Starting Member
4 Posts |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-05-01 : 19:14:27
|
I still say you should use TIME data type. You can then display the required format by coding the convert in your application.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
sqlqueries
Starting Member
4 Posts |
Posted - 2015-05-01 : 19:17:03
|
Thank you very much Tara Kizer. |
|
|
|
|
|