﻿{"id":1328,"date":"2010-09-23T11:04:27","date_gmt":"2010-09-23T03:04:27","guid":{"rendered":"http:\/\/blog.jixin.ntxz.net\/?p=1328"},"modified":"2010-09-23T11:04:27","modified_gmt":"2010-09-23T03:04:27","slug":"sql%e6%9f%a5%e8%af%a2%e6%9c%88%e3%80%81%e5%a4%a9%e3%80%81%e5%91%a8%e3%80%81%e5%b9%b4%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"http:\/\/www.ntxz.net\/?p=1328","title":{"rendered":"SQL\u67e5\u8be2\u6708\u3001\u5929\u3001\u5468\u3001\u5e74\u6570\u636e"},"content":{"rendered":"<p>\u8ba1\u7b97\u4eca\u5929\u662f\u661f\u671f\u51e0<br \/>\n select datename(weekday,getdate()) <\/p>\n<p>\u67e5\u8be2\u672c\u5e74\u7684\u6570\u636e<br \/>\n select * from  users where year(time)=year(getdate())   <\/p>\n<p>\u67e5\u8be2\u672c\u6708\u7684\u6570\u636e\uff0ctime\u662f\u8868users\u4e2d\u4ee3\u8868\u65f6\u95f4\u7684\u5b57\u6bb5<br \/>\n select * from users where month(time)=month(getdate()) and year(time)=year(getdate())<\/p>\n<p>\u67e5\u8be2\u4eca\u5929\u7684\u6570\u636e\uff0ctime \u662f\u8868\u4e2d\u4ee3\u8868\u65f6\u95f4\u7684\u5b57\u6bb5<br \/>\n select * from users where day(time)=day(getdate()) and month(time)=month(getdate()) and year(time)=year(getdate())<\/p>\n<p>\u8ba1\u7b97\u90a3\u4e00\u5929\u662f\u661f\u671f\u4e00<br \/>\n SELECT  DATEADD(wk,  DATEDIFF(wk,0,getdate()),  0)  <\/p>\n<p>\u8ba1\u7b97\u90a3\u4e00\u5929\u662f\u5468\u672b<br \/>\n select dateadd(wk,datediff(wk,0,getdate()),6)<\/p>\n<p>\u67e5\u8be2\u672c\u5468\u7684\u6570\u636e<br \/>\n select * from users where DATEPART(wk, time) = DATEPART(wk, GETDATE()) and DATEPART(yy, time) = DATEPART(yy, GETDATE()) <\/p>\n<p>\u67e5\u8be2\u672c\u65e5\u7684\u8bb0\u5f55<br \/>\n select * from users where (DATEDIFF(dd, time, GETDATE()) = 0)<\/p>\n<p>*\u67e5\u8be2\u672c\u6708\u7684\u8bb0\u5f55<br \/>\n select * from users where (DATEDIFF(mm, time, GETDATE()) = 0)<\/p>\n<p>\u67e5\u8be2\u672c\u5e74\u7684\u8bb0\u5f55<br \/>\n  select * from users where (DATEDIFF(yy, time, GETDATE()) = 0)\u5728MySql\u4e2d\u5b9e\u73b0<\/p>\n<p>   \u672c\u5e74\uff1a<br \/>\n   select   *   from   loanInfo   where   year(date)=year(getdate())   <\/p>\n<p>   \u672c\u6708\uff1a<br \/>\n   select   *   from   loanInfo   where   year(date)=year(getDate())   And   month(date)=month(getdate())   <\/p>\n<p>  \u672c\u65e5\uff1a<br \/>\n   select   *   from   loanInfo   where   year(date)=year(getDate())   And   month(date)=month(getdate())   and   Day(date)=Day(getDate())  <\/p>\n<p>15SELECT   *    FROM   table    WHERE   (MONTH(\u5b57\u6bb5)   =   MONTH(GETDATE()))  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8ba1\u7b97\u4eca\u5929\u662f\u661f\u671f\u51e0 select datename(weekday,getdate()) \u67e5\u8be2\u672c\u5e74\u7684\u6570\u636e sel [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[218,111,220,221,219,217],"class_list":["post-1328","post","type-post","status-publish","format-standard","hentry","category-fromnetwork","tag-benyue","tag-sql","tag-220","tag-221","tag-219","tag-217"],"views":762,"_links":{"self":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts\/1328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1328"}],"version-history":[{"count":1,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts\/1328\/revisions"}],"predecessor-version":[{"id":1329,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=\/wp\/v2\/posts\/1328\/revisions\/1329"}],"wp:attachment":[{"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1328"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ntxz.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}