i am trying to add milliseconds to a time. For example if i have a time of 01:01:05:000 and i want to add 0.297 milliseconds to it i use the following simplified query
SELECT CONVERT(nvarchar(20), DATEADD(ms, 0.297, '00:01:05:000'), 14) AS Expr1
However instead of getting 01:01:05:0.297 i get 01:01:05:000. Can somebody please tell me what i am doing wrong.
Thanks in advance.Try:
SELECT CONVERT(nvarchar(20), DATEADD(ms, 297, '00:01:05:000'), 14) AS Expr1
Terri|||hi tmorton, thanks for the reply, however what if the vlaue to add in milliseconds is 0.297? How would i change the sql query?|||0.297 milliseconds, as in 0.000297 seconds? Sorry, SQL Server is not that granular. SQL Server is accurate only down to 3.33 millseconds. You can read up ondatetime and smalldatetime (Transact-SQL Reference (SQL Server)).
Terri|||ok got it working,
SELECT CONVERT(varchar(20), DATEADD(ms, Exec_Time * 1000, CONVERT(varchar(20), [date], 14)), 14)
AS Expr1
FROM llserverlogs
WHERE (Server = 'llkwa001-ukbg')
ORDER BY [date]
thanks for the help
No comments:
Post a Comment