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 |
|
Ambikaa
Starting Member
43 Posts |
Posted - 2009-02-22 : 06:35:28
|
| Hi,I need to convert smalldatetime datatype column to milliseconds?original data BeginTime1899-12-30 01:00:00.0001899-12-30 19:00:00.0001899-12-30 20:00:00.0001899-12-30 20:15:00.0001899-12-30 19:10:00.000through this query i got this o/p SELECT CONVERT(VARCHAR(8), begintime, 108)from demo3Begin Time01:00:0019:00:0020:00:0020:15:0019:10:00but, i need only milliseconds how can i achieve it? |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-22 : 08:46:03
|
| [code]SELECT Substring(Right(Convert(varchar(40),getdate(),109),5),1,3)[/code] |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-02-24 : 01:57:01
|
| No need to convert.Just use thisselect datepart (ms,begintime ) as 'MilliSeconds' from demo3 |
 |
|
|
Ambikaa
Starting Member
43 Posts |
Posted - 2009-02-24 : 02:10:51
|
quote: Originally posted by raky No need to convert.Just use thisselect datepart (ms,begintime ) as 'MilliSeconds' from demo3
It shows only zero value. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-24 : 02:23:12
|
| see this ambikaa,in ur data there is only zero for millisecondscheck this query onceselect getdate(),datepart (ms,getdate() ) as 'MilliSeconds' |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2009-02-24 : 04:00:23
|
| Ambikaa, in your original posting, you said the datatype is smalldatetime. If that is true, then your millisecond part will always be zero. This is because smalldatetime precision is only to the minute. Use datetime rather than smalldatetime and you will get precision to milliseconds (actually to 3.333 milliseconds precision) |
 |
|
|
|
|
|
|
|