epoch time to datetime

CREATE FUNCTION convertEpoch

(@epochVal bigint) RETURNS datetime

AS BEGIN DECLARE @Return datetime

SELECT @return = dateadd(s,@epochVal/1000,'1970-01-01')

RETURN @return END



Convert UTC Time to Local Time

DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), [table field] )  AS ColumnInLocalTime