Convert date to unix timestamp

Giganews Newsgroups
Subject: Convert date to unix timestamp
Posted by:  luisdev (andy…@webmail.co.za)
Date: Sun, 14 Aug 2011

How do I convert a "YYYY/MM/DD" date into a unix timestamp? Using the
DATEDIFF function in the second INSERT below does not seem to work.

CREATE TABLE DateTest(
  ACTIVITYDATE [nvarchar](50) NULL,
  UNIXACTIVITYDATE [bigint] NULL
)

INSERT INTO DateTest (ACTIVITYDATE)
VALUES ('2011/02/03')

INSERT INTO DateTest (UNIXACTIVITYDATE)
SELECT DATEDIFF(ss,'1970.01.01 00:00:00:000',ACTIVITYDATE)

Thanks.

Replies