Marcus Aurelius
asked on
How do I ADD milliseconds to a DATE/TIME FIELD?
Experts:
I have a TIME field that looks like this:
1899-12-30 23:31:09.000
I have a DURATION field that is stored in MILLISECONSD and looks like this:
7209
What is the "syntax" to use to ADD the MILLISECONDS to the TIME field in order to obtain the exact time after the DURATION of the milliseconds?
Thanks
M
I have a TIME field that looks like this:
1899-12-30 23:31:09.000
I have a DURATION field that is stored in MILLISECONSD and looks like this:
7209
What is the "syntax" to use to ADD the MILLISECONDS to the TIME field in order to obtain the exact time after the DURATION of the milliseconds?
Thanks
M
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Not all do this but a great majority do add the few milliseconds to the calc...???
SQL Server's datetime data type is not infinitely granular.
select convert(datetime, '1899-12-30 21:33:02.055', 21)
Yields:
'1899-12-30 21:33:02.057'
select convert(datetime, '1899-12-30 21:33:02.055', 21)
Yields:
'1899-12-30 21:33:02.057'
ASKER
Ok...thanks for the great info....
If you require accuracy of more than about 3 milliseconds then you could upgrade to SQL Server 2008 which supports datetime accuracy to 100 nanoseconds.
If that's not possible then you'll have to use a non-datetime type in 2005. You could use a SMALLINT for the milliseconds.
If that's not possible then you'll have to use a non-datetime type in 2005. You could use a SMALLINT for the milliseconds.
ASKER
Here is my TimeField-
1899-12-30 21:33:02.000
And here is my Duration Field-
55
When I use this in a column:
, dateadd(ms, prequeue, start_time) as [StartTime + PreQueue]
I get this:
1899-12-30 21:33:02.057
Just curious, why does it add 2 milliseconds to the calc....???