I need to update a field (True_Poss) to reflect the number of days from the 15th of last month to the date in the field called (Dte_Reported). Here is what I am trying, but I get an Incorrect syntax near '=' error. I have tried variations of Set tablename.true_poss, etc. same results.
Any ideas?
Declare @Mmonth char(2)
Declare @MYear Int
Declare @MDate char(4)
Declare @MCurDate SmallDatetime
Declare @MLastDate SmallDatetime
Declare @SQLString varchar(200)
SET @MDate = '/15/'
BEGIN
UPDATE dbo.XMF_NMC
SET @MCurDate = dbo.XMF_NMC.Dte_Reported
SET @MYear = Year(Dte_Reported - 30)
SET @Mmonth = Month(Dte_Reported - 30)
SET @MLastDate = (Mmonth + MDate + MYear)
SET True_Poss = (DATEDIFF(day, @MLastDate, @MCurDate) )
END
Larry
Any ideas?
Declare @Mmonth char(2)
Declare @MYear Int
Declare @MDate char(4)
Declare @MCurDate SmallDatetime
Declare @MLastDate SmallDatetime
Declare @SQLString varchar(200)
SET @MDate = '/15/'
BEGIN
UPDATE dbo.XMF_NMC
SET @MCurDate = dbo.XMF_NMC.Dte_Reported
SET @MYear = Year(Dte_Reported - 30)
SET @Mmonth = Month(Dte_Reported - 30)
SET @MLastDate = (Mmonth + MDate + MYear)
SET True_Poss = (DATEDIFF(day, @MLastDate, @MCurDate) )
END
Larry