I have a SQL function that was provided which convert epoch to a date time.
The issues that this sql function does not work for dates before 1/3/1970. Does anyone have any ideas to make this work for dates less than 1970.
DECLARE @total bigint
--if greater than 12/31/9999 return null
IF @total > 253402232400000
RETURN NULL
--if less than or equal 1/3/1970 return null
IF @total <= 18000000
RETURN NULL
DECLARE @seconds int = @total / 86400000;
DECLARE @milliseconds int = @total % 86400000;
DECLARE @result datetime = '1970-1-1';
SET @result = DATEADD(DAY, @seconds,@result);
SET @result = DATEADD(MILLISECOND, @milliseconds,@result);
RETURN @result;