开发者

What's the equivalent of php time() in mssql?

For example if I execute the code below under my Windows 7-I have PHP running under windows 7/IIS.

echo time() I will get this 1304972050

How can I get the same result in MSS开发者_如何学PythonQL?


SELECT DATEDIFF(ss, '1/1/1970 05:00:00', GETUTCDATE())

Should do.

UPDATED per comment.


To get the epoch time in sql:

SELECT DATEDIFF(s,'19700101 05:00:00:000',GETUTCDATE())


You don't get this out of the box, but you can find functions defined on sql server forums, eg. http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=66858.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜