我想减去4个月,期间定义为年月:
UPDATE [MAS_YCA].[dbo].[temp_AR_SalesPersonhistory]
SET FiscalYear = year(DATEADD(month,-4,DATEADD(DAY,-1,DATEADD(month,cast(FiscalPeriod as Int),DATEADD(year,cast(FiscalYear as Int)-1900,0))))),
FiscalPeriod = right('00'+cast(month(DATEADD(month,-4,DATEADD(DAY,-1,DATEADD(month,cast(FiscalPeriod as Int),DATEADD(year,cast(FiscalYear as Int)-1900,0))))) as varchar),02)
GO
我得到的错误是Adding value to a datetime column caused an overflow.
字段会计年度和期间在数据表中都定义为 varchar。