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 |
rohitmathur11
Yak Posting Veteran
77 Posts |
Posted - 2010-01-18 : 03:32:55
|
In table we have datetime datatype .. I want to store only time in the table column. How can i do this .. |
|
Kristen
Test
22859 Posts |
Posted - 2010-01-18 : 03:36:51
|
There is a TIME datatype, which was introduced in SQL 2008.Before that / traditionally TIME was been stored in a DATETIME datatype.You can do this:DECLARE @MyTime DATETIMESELECT @MyTime = '01:02:03.456'SELECT @MyTime and you get: 1900-01-01 01:02:03.457 (note that milliseconds are not stored exactly in DATETIME).However, apart from the 01-Jan-1900 date part, the time can be manipulated as normal:SELECT DATEADD(Minute, 10, @MyTime) -- Add 10 minutesgives: 1900-01-01 01:12:03.457SELECT CONVERT(varchar(8), @MyTime, 108)gives: 01:02:03 |
 |
|
rohitmathur11
Yak Posting Veteran
77 Posts |
Posted - 2010-01-18 : 05:17:57
|
Thanks a lot SO in 2005 we can store time only through progam leval ..like front end ..at database leval we can take only datatime datatype .. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-18 : 05:23:33
|
quote: Originally posted by rohitmathur11 Thanks a lot SO in 2005 we can store time only through progam leval ..like front end ..at database leval we can take only datatime datatype ..
YesMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|