在sql中用于截取时间的方法

一,截取的到的年月

select convert(char(7),'2013-04-12 09:32:28.000',120);

结果 2013-04

select SUBSTRING(getdate(),0,8) ;

二,截取到年月日

select convert(varchar(10),getdate(),120);

三,截取时间(HH:MM:SS)

select convert(varchar(8),getdate(),108);

posted @ 2013-04-12 10:16  詺*篂  阅读(333)  评论(0编辑  收藏  举报