select left(CONVERT(nvarchar, 费用日期, 102),4)+'年'+SUBSTRING(CONVERT(nvarchar, 费用日期, 102),3,2)+'月'+right(CONVERT(nvarchar, 费用日期, 102),2)+'日' from view_cb_feiyong
select convert(varchar(4),workday, 120)+'年'+right(convert(varchar(7),workday,120),2)+'月'+right(convert(varchar(10),workday, 120),2) + '日' from table1
--我觉得'yyyy-mm-dd'就可以了, 不是一定要搞成yyy年mm月dd日吧? declare @date datetime, @ymd varchar(10) set @date=getdate() --转化 set @ymd=substring(convert(varchar(20), @date, 120), 1, 10) --显示结果 select @ymd
declare @date datetime set @date=getdate() select cast(datepart(yy,@date) as varchar(10))+'年' +cast(datepart(mm,@date) as varchar(10))+'月' +cast(datepart(dd,@date) as varchar(10))+'日'
另外一个方法: declare @date datetime set @date=getdate() select cast(Year(@date) as varchar(10))+'年' +cast(Month(@date) as varchar(10))+'月' +cast(Day(@date) as varchar(10))+'日'
select left(CONVERT(nvarchar, 费用日期, 102),4)+'年'+SUBSTRING(CONVERT(nvarchar, 费用日期, 102),3,2)+'月'+right(CONVERT(nvarchar, 费用日期, 102),2)+'日' from view_cb_feiyong
declare @date datetime, @ymd varchar(10)
set @date=getdate()
--转化
set @ymd=substring(convert(varchar(20), @date, 120), 1, 10)
--显示结果
select @ymd
set @date=getdate()
select cast(datepart(yy,@date) as varchar(10))+'年'
+cast(datepart(mm,@date) as varchar(10))+'月'
+cast(datepart(dd,@date) as varchar(10))+'日'
declare @date datetime
set @date=getdate()
select cast(Year(@date) as varchar(10))+'年'
+cast(Month(@date) as varchar(10))+'月'
+cast(Day(@date) as varchar(10))+'日'