ms sql server下unix时间戳函数unix_timestamp, from_unixtime(与mysql兼容)
直接上代码:
CREATE FUNCTION UNIX_TIMESTAMP (@ctimestamp datetime) RETURNS integer
AS
BEGIN
/* Function body */
declare @return integer
SELECT @return = DATEDIFF(SECOND,{d '1970-01-01'}, @ctimestamp)
return @return
END
CREATE FUNCTION from_unixtime (@ts integer) RETURNS datetime
AS[......]