SQL 获取当前日期,年、月、日、周、时、分、秒

?select GETDATE() as '当前日期',
DateName(year,GetDate()) as '年',
DateName(month,GetDate()) as '月',
DateName(day,GetDate()) as '日',
DateName(dw,GetDate()) as '星期',
DateName(week,GetDate()) as '周数',
DateName(hour,GetDate()) as '时',
DateName(minute,GetDate()) as '分',
DateName(second,GetDate()) as '秒'

结果:

2009-08-13 23:07:15.403 2009 08 13 星期四 33 23 7 15

 

本文来自CSDN博客:http://blog.csdn.net/ddjiang1115/archive/2010/08/27/5843522.aspx


select getdate()

2012-05-21 16:42:17.373

 

select  datename(year,getdate()) 

2012

posted @ 2012-05-21 16:41  小四儿  阅读(640)  评论(0编辑  收藏  举报