1. February 2011 18:51
It's something that all of a sudden when you think you need it. You cant think of how to do it.
So here is a quick function that turns a unix timestamp into a datetime
CREATE FUNCTION [dbo].[UNIXToDateTime] (@timestamp int)
RETURNS datetime
AS
BEGIN
DECLARE @ret datetime
SELECT @ret = DATEADD(second, @timestamp, '1970/01/01 00:00:00')
RETURN @ret
END
GO
An example on how to use it
SELECT dbo.UNIXToDateTime(dbo.DateTimeToUNIX(GETDATE()))
You may also want to see the convert to unix timstamp function
267050d7-66c8-4fda-afd5-3ebc5032ac21|0|.0