ms sql server中实现的unix时间戳函数(含生成和格式化,可以和mysql兼容)
直接上代码:
CREATEFUNCTIONUNIX_TIMESTAMP(@ctimestampdatetime)RETURNSinteger
AS
BEGIN
/*Functionbody*/
declare@returninteger
SELECT@return=DATEDIFF(SECOND,{d'1970-01-01'},@ctimestamp)
return@return
END
CREATEFUNCTIONfrom_unixtime(@tsinteger)RETURNSdatetime
AS
BEGIN
/*Functionbody*/
declare@returndatetime
select@return=DATEADD(second,@ts,{d'1970-01-01'})
return@return
END
用法
跟MySQL下的一样类似:
selectdbo.UNIX_TIMESTAMP('2013-1-1')
selectdbo.from_unixtime(2145000000)热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语