{"id":3205,"date":"2015-10-29T09:46:28","date_gmt":"2015-10-29T09:46:28","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=3205"},"modified":"2015-10-30T03:51:07","modified_gmt":"2015-10-30T03:51:07","slug":"mysql%e6%97%b6%e9%97%b4%e6%88%b3timestamp%e5%9c%a8sqlserver%e4%b8%ad%e7%9a%84%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/enjoyasp.net\/index.php\/2015\/10\/29\/mysql%e6%97%b6%e9%97%b4%e6%88%b3timestamp%e5%9c%a8sqlserver%e4%b8%ad%e7%9a%84%e5%ae%9e%e7%8e%b0\/","title":{"rendered":"mysql\u65f6\u95f4\u6233timestamp\u5728sqlserver\u4e2d\u7684\u5b9e\u73b0"},"content":{"rendered":"<pre class=\"brush:sql;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;\">\r\n\r\nCREATE FUNCTION [dbo].[UNIX_TIMESTAMP]\r\n(\r\n    @DATE DATETIME=&#39;&#39;\r\n)\r\n       \r\nRETURNS DECIMAL\r\nAS\r\nBEGIN\r\n\u3000\u3000--\u6ce8\u610f\u65f6\u533a\uff0c\u5317\u4eac\u65f6\u95f4\u7edf\u4e00\u51cf8\u53d8\u6210\u683c\u6797\u5c3c\u6cbb\u65f6\u95f4\r\n  \u3000IF @DATE=&#39;&#39; SET @DATE=GETDATE()\r\n\u3000\u3000SET @DATE=DATEADD(HOUR,-8,@DATE)\r\n  \u3000RETURN DATEDIFF(SECOND,&#39;1970-01-01&#39;,@DATE)\r\n      \r\nEND\r\n\r\nCREATE FUNCTION [dbo].[FROM_UNIXTIME]\r\n(\r\n    @i DECIMAL\r\n)\r\n       \r\nRETURNS VARCHAR(20)\r\nAS\r\nBEGIN\r\n\u3000RETURN CONVERT(VARCHAR(20),DATEADD(SECOND,@i+28800,&#39;1970-01-01&#39;),120) --\u5317\u4eac\u65f6\u95f4\u8981\u52a0\u56de8*3600=28800\u79d2\r\nEND\r\n\r\n<\/pre>\n<p>\n\u5f15\u81ea\uff1a<a href=\"http:\/\/blog.cozof.com\/pieces\/31.shtml\">MSSQL(SQL SERVER)\u4e2d\u83b7\u53d6UNIX\u65f6\u95f4\u6233<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CREATE FUNCTION [dbo].[UNIX_TIMESTAMP] ( @DATE DATETIME [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,36],"tags":[],"class_list":["post-3205","post","type-post","status-publish","format-standard","hentry","category-sql","category-sql-server"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/3205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/comments?post=3205"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/3205\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=3205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=3205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=3205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}