Add Milliseconds to Datetime
Posted on 2006-11-02
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
ALTER PROCEDURE [dbo].[spInsertEvent]
@TransactionTimestamp datetime = NULL,
@TransactionMilliseconds int = NULL,
@DatapointName varchar(64) = NULL,
@EventValue int = NULL
INSERT INTO Events
(TransactionTimestamp, DatapointName, EventValue)
(@TransactionTimestamp + @TransactionMilliseconds, @DatapointName, @EventValue)
DECLARE @return_value int
SET @return_value = 0