SQL获取当前日期的年、月、日、时、分、秒数据
SELECT GETDATE() as '当前日期', 2020-07-24 09:45:55.160
DateName(year,GetDate()) as '年', 2020
DateName(month,GetDate()) as '月', 07
DateName(day,GetDate()) as '日', 24
DateName(dw,GetDate()) as '星期', 星期五
DateName(week,GetDate()) as '周数', 30
DateName(hour,GetDate()) as '时', 9
DateName(minute,GetDate()) as '分', 45
DateName(second,GetDate()) as '秒' 55
2020-07-24 09:45:55.160 2020 07 24 星期五 30 9 45 55
--获取当前日期的前一天
select convert(char(10),getdate()-1,120) 2020-07-23