T-SQL Function to convert Unix Timestamp into MS SQL datetime « ProgAdv


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. CREATE FUNCTION UNIX_TIMESTAMP_TO_DATETIME (
  2. @TIMESTAMP INTEGER
  3. )
  4. RETURNS datetime
  5. AS
  6. BEGIN
  7. /* Function body */
  8. DECLARE @RETURN datetime
  9.  
  10. SELECT @RETURN = DATEADD(SECOND, @TIMESTAMP,{d '1970-01-01'});
  11.  
  12. RETURN @RETURN
  13. END

URL: http://skinn3r.wordpress.com/2009/01/26/t-sql-function-to-convert-unix-timestamp-into-ms-sql-datetime/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.