提取年:select datepart(yy,getdate()) as year
提取月:select datepart(mm,getdate()) as month
提取日:select datepart(dd,getdate()) as day
提取季度:select datepart(quarter,getdate())
------------------------------------------------------------------------------------------------------------------
Datepart():返回代表指定日期的指定日期部分的整数
语法:Datepart(datepart,date) 返回类型:int
DateName():返回代表指定日期的指定日期部分的字符串
语法:DateName(datepart,date) 返回类型:nvarchar
=====================================================
DateName(quarter,GetDate()) as ‘第几季度’,
DateName(week,GetDate()) as ‘一年中的第几周’,
DateName(DAYOFYEAR,GetDate()) as ‘一年中的第几天’,
DateName(year,GetDate()) as ‘年’,
DateName(month,GetDate()) as ‘月’,
DateName(day,GetDate()) as ‘日’,
DateName(hour,GetDate()) as ‘时’,
DateName(minute,GetDate()) as ‘分’,
DateName(second,GetDate()) as ‘秒’,
DateName(MILLISECOND,GetDate()) as ‘豪秒’,
DateName(WEEKDAY,GetDate()) as ‘星期几’