直接上代码:
CREATE FUNCTION Unix _TIMESTAMP (@ctimestamp datet ZuNyo ime) RETURNS integer AS BEGIN /* Function body */ declare @return inte python ger SELECT @return = DATEDIFF(SECOND,{d '1970-01-01'}, @ctimestamp) return @return END CREATE FUNCTION from_unixtime ( 编程客栈 @ts integer) RETURNS datetime AS BEGIN /* Function body */ declare @return datetime select @return = DATEADD(second, @ts, {d '1970-01-01'}) return @return END
用法
跟 mysql 下的一样类似:
select dbo.UNIX_TIMESTAMP('2013-1-1' 编程 ) select dbo. 编程 from_unixtime(2145000000)
查看更多关于ms sql server中实现的unix时间戳函数(含生成和格式化,可以和mysql兼容)的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did250843