select GETDATE()
--2016-01-08 16:15:05.787
select convert(varchar,getdate(),11)
--16/01/08
select convert(varchar,getdate(),23)
--2016-01-08
select convert(varchar,getdate(),24)
--16:39:10
select convert(varchar,getdate(),102)
--2016.01.08
select convert(varchar,getdate(),104)
--08.01.2016
select convert(varchar,getdate(),111)
--2016/01/08
select convert(varchar,getdate(),112)
--20160108
select convert(varchar,getdate(),114)
--16:19:27:533
select convert(varchar,getdate(),120)
--2016-01-08 16:18:39
select convert(varchar,getdate(),0)
--01 8 2016 4:29PM
select convert(varchar,getdate(),1)
--01/08/16
select convert(varchar,getdate(),2)
--16.01.08
select convert(varchar,getdate(),3)
--08/01/16
select convert(varchar,getdate(),4)
--08.01.16
select convert(varchar,getdate(),5)
--08-01-16
select convert(varchar,getdate(),6)
--08 01 16
select convert(varchar,getdate(),7)
--01 08, 16
select convert(varchar,getdate(),8)
--16:33:17
select convert(varchar,getdate(),9)
--01 8 2016 4:34:51:290PM
select convert(varchar,getdate(),10)
--01-08-16
select convert(varchar,getdate(),12)
--160108
select convert(varchar,getdate(),13)
--08 01 2016 16:36:08:463
select convert(varchar,getdate(),14)
--16:36:17:170
select convert(varchar,getdate(),20)
--2016-01-08 16:38:36
select convert(varchar,getdate(),21)
--2016-01-08 16:38:44.963
select convert(varchar,getdate(),22)
--01/08/16 4:39:02 PM
select convert(varchar,getdate(),100)
--01 8 2016 4:44PM
select convert(varchar,getdate(),101)
--01/08/2016
select convert(varchar,getdate(),103)
--08/01/2016
select convert(varchar,getdate(),105)
--08-01-2016
select convert(varchar,getdate(),106)
--08 01 2016
select convert(varchar,getdate(),107)
--01 08, 2016
select convert(varchar,getdate(),108)
--16:47:16
select convert(varchar,getdate(),109)
--01 8 2016 4:47:24:130PM
select convert(varchar,getdate(),110)
--01-08-2016
select convert(varchar,getdate(),113)
--08 01 2016 16:41:46:303
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
--20160108165418
--获取本周
select * from NCIC2009_InterfaceLog where datediff(week,FDATE,getdate())=0
--获取本月
select * from NCIC2009_InterfaceLog where datediff(month,FDATE,getdate())=0
--本季度
select * from NCIC2009_InterfaceLog where datediff(qq,FDATE,getdate())=0
--1-6 /7-12 前半年/后半年
select * from NCIC2009_InterfaceLog where datepart(mm,FDATE)/7 = datepart(mm,getdate())/7
--加两天
select dateadd(day,2,getdate())
--获取两个日期的时间差几天
select datediff(day,'2016-08-01','2016-09-01')
--日期的月份
select DATEPART(month, getdate())
--获取当前日期的星期
select datename(weekday, getdate())
select datename(dw,getdate())
--当前年的第多少周
select datename(week,getdate())
select datename(weekday,getdate())
--获取当前日期的最大天数
SELECT DAY(DATEADD(dd, -1, DATEADD(mm, 1, DATEADD(dd, 1-DAY(getdate()),getdate())))) AS 'Day Number'