处理应该返回日期的函数。但是我得到了这个错误,我不确定如何修复它
if (@flow_date = eomonth(@flow_date) or day(@flow_date) < day(@lMaturityDate)) begin
set @lMaturityDate = eomonth(@lMaturityDate);
end
else begin
if month(@lMaturityDate) < 10 BEGIN
set @month=concat('0',month(@lMaturityDate));
end
else Begin
set @month=month(@lMaturityDate);
END
set @lMaturityDate =convert(date,concat(year(@lMaturityDate),'-',@month,'-',day(@flow_date)))
end
END
return isnull(@lMaturityDate,null);
END
导致错误的示例代码,我只是注意到它抛出错误的时间长于10个月
declare @month varchar(40);
declare @lMaturityDate date = '2019-11-31'
declare @flow_date date = '2019-04-25'
if month(@lMaturityDate) < 10 BEGIN
set @month=concat('0',month(@lMaturityDate));
end
else Begin
set @month=month(@lMaturityDate);
END
set @lMaturityDate =convert(date,concat(year(@lMaturityDate),'-',@month,'-',day(@flow_date)))
select @lMaturityDate
https://stackoverflow.com/questions/56247968
复制相似问题