欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ms sql server中實現(xiàn)的unix時間戳函數(shù)(含生成和格式化,可以和mysql兼容)

 更新時間:2014年07月03日 10:56:04   投稿:junjie  
這篇文章主要介紹了ms sql server中實現(xiàn)的unix時間戳函數(shù),含生成和格式化UNIX_TIMESTAMP、from_unixtime兩個函數(shù),可以和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
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)

相關(guān)文章

最新評論