22,210
社区成员
发帖
与我相关
我的任务
分享
create table #temp (inter_date datetime)
insert into #temp values('2010-09-17')
insert into #temp values('2011-02-22')
insert into #temp values('2014-12-02')
insert into #temp values('2016-03-04')
select inter_date,GETDATE(),((case DATEDIFF(mm,inter_date,GETDATE())/12 when 0 then '' else convert(varchar,DATEDIFF(mm,inter_date,GETDATE())/12)+'年' end)
+ (case DATEDIFF(mm,inter_date,GETDATE())%12 when 0 then '' else convert(varchar,DATEDIFF(mm,inter_date,GETDATE())%12)+'个月' end)) from #temp
drop table #temp
可以考虑些个函数