日期:2014-05-17 浏览次数:20594 次
declare @x datetime
select @x='2013-06-01 00:00:00'
select left(convert(varchar,@x,120),7) 'x'
/*
x
--------------
2013-06
(1 row(s) affected)
*/
declare @x datetime
select @x='2013-06-01 00:00:00'
SELECT SUBSTRING(convert(varchar,@x,120),1,7)
/*
--------------
2013-06
*/