I have a DB that has a table with CCExpDate as credit card expiration. It is currently in format MMYY and data type is varchar. I would like to be able to update these dates to reflect any expired dates as of today are updated where Field (CCNo = 4 or 5) ADD + 2 years and where (CCNo= 3) ADD + 3 years.
I should be able to run this whenever necessary.
This is a question that has been reopened because we are still having issues with it.
The field in question is varchar in format as such '1206'
I have listed the latest from another contributor.
When running the above query.. it captures Oct, Nov and Dec.. but... it updates them beyond where they should. For instance, I ran it on 1106 and it updated to 1110. In fact.. it should only update to 1108 because that would still be valid. Did same thing for 1206.. it updated to 1210 when it shouldve updated to 1208.
Thanks for your help
SET CCExpDate = RIGHT('00' + Left(CCExpDate,2),2) +
Right('00' + Cast((Cast(Right(year(getdate()),2) as smallint) + 2) As Varchar),2)
WHERE (Cast(Left(CCExpDate,2) as smallint) <= (Month(GetDate())-1)
AND Cast(Right(CCExpDate,2) as smallint) <= Cast(Right(Year(GetDate()),2) as Smallint)
OR Cast(Right(CCExpDate,2) as smallint) < Cast(Right(Year(GetDate()),2) as Smallint) )
AND CCNo like '387845635%'