I have this statement
EXEC [spProject_Update] @ProjectID = 496
,@Name = 'Hangman Bollywood iPhone'
,@Description = ''
,@EstimateTime = 2674800000
I will get milliseconds in @EstimateTime
.
How can I convert this to datetime
in SQL Server?
DATETIME
is used to store an instant ("point in time") at a particular granularity (approx 300 milliseconds IIRC).
The value you wish to store is an interval (or is it a duration?) in milliseconds. SQL Server lacks an interval data type.
While both are temporal data they have quite different requirements. I suggest you use an numeric column (e.g. INTEGER
) to store the interval and use metadata (e.g. an appropriate name) to convey the fact the granularity is one millisecond.
1 Jan 1900
then2674800000
milliseconds is only743
hours so doesn't seem likely.DATEADD(MILLISECOND, 2674800000,0)
fails with an overflow error.DATEADD(SECOND, 2674800,0)
works but I presume that you aren't actually going to be using dates in 1900 so that will overflow too. Why not just pass in asdatetime
?int
rather than a nonsensicaldatetime
?