开发者

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

开发者 https://www.devze.com 2023-03-03 20:16 出处:网络
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

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

精彩评论

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