sqlの日付を調べます。
8916 ワード
:select * from where DateDiff(dd,datetime ,getdate())=0
:select * from where DateDiff(dd,datetime ,getdate())=1
7 :select * from where DateDiff(dd,datetime ,getdate())<=7
30 :select * from where DateDiff(dd,datetime ,getdate())<=30
:select * from where DateDiff(mm,datetime ,getdate())=0
:select * from where DateDiff(yy,datetime ,getdate())=0
: select datepart(dayofyear,getDate())
:1. select datepart(dd, getDate())
2.select day(getDate())
( : , 。 ) SELECT DATEADD(wk,DATEDIFF(wk,0,getdate()),0)
:select convert(char,dateadd(DD,-1,getdate()),111) //111 ,(100-114)
:Select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0) as firstday
:Select dateadd(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate())+1, 0)) as lastday // -3
:select datepart(dd,dateadd(dd,-1,dateadd(mm,1,cast((cast(year(getdate()) as varchar)+'-'+cast(month(getdate()) as varchar)+'-01' ) as datetime ))))
:select datediff(day,'2012/8/1','2012/8/20') as daysum
±N :select convert(char,dateadd(dd,1,'2012/8/20'),111) as riqi // 2012/8/21
±N :select dateadd(mi,-15,getdate()) // 15
: select dateadd(day,3,'20151105') // 2015-11-08 00:00:00.000
転載先:https://www.cnblogs.com/YzpJason/p/6579669.html