bryker
asked on
Add Milliseconds to Datetime
I have an external system that will be calling my SP with a datetime value, and with a milliseconds value that I want to add to that datetime value as I insert it into my database.
Currently, I have this, which does not add the 2 values together. Can someone help me with whatever CAST or CONVERT call I need to make in order to add these 2 values together either just before or as I insert the timestamp into the table?
Thanks very much.
========================== ========== =======
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[spInsertEvent]
@TransactionTimestamp datetime = NULL,
@TransactionMilliseconds int = NULL,
@DatapointName varchar(64) = NULL,
@EventValue int = NULL
AS
BEGIN
INSERT INTO Events
(TransactionTimestamp, DatapointName, EventValue)
VALUES
(@TransactionTimestamp + @TransactionMilliseconds, @DatapointName, @EventValue)
DECLARE @return_value int
SET @return_value = 0
END
GO
Currently, I have this, which does not add the 2 values together. Can someone help me with whatever CAST or CONVERT call I need to make in order to add these 2 values together either just before or as I insert the timestamp into the table?
Thanks very much.
==========================
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[spInsertEvent]
@TransactionTimestamp datetime = NULL,
@TransactionMilliseconds int = NULL,
@DatapointName varchar(64) = NULL,
@EventValue int = NULL
AS
BEGIN
INSERT INTO Events
(TransactionTimestamp, DatapointName, EventValue)
VALUES
(@TransactionTimestamp + @TransactionMilliseconds, @DatapointName, @EventValue)
DECLARE @return_value int
SET @return_value = 0
END
GO
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Why does it round if i'm putting DATEADD(ms, 999, @date), it's rounding UP to the next second, which doesn't help