Trouble with updating a DATE in SQL table

I am having trouble updating a DATE in SQL table.
My code is:
Update Customer Set LTEmailOKSendYN=0, LTEmailDate=DATEADD(month, 9, LTEmailDate)
	Where MainID=@MainID

Open in new window

I am trying to add 9 months to the date currently in the SQL table (LTEmailDate).
I am getting very weird results! Help!
SOTAAsked:
Who is Participating?
 
Scott PletcherSenior DBACommented:
Best (educated) guess: somehow the UPDATE is occurring twice; 18 months were added rather than 9.

May also want to look for trigger(s) on the table.
0
 
Scott PletcherSenior DBACommented:
Don't know specifically what you mean by "weird", but your UPDATE looks fine:

Update Customer
Set
    LTEmailOKSendYN=0,
    LTEmailDate=DATEADD(month, 9, LTEmailDate)
Where MainID=@MainID
0
 
ste5anSenior DeveloperCommented:
Weird? How comes?

btw, posting a concise and complete sample would help. Context!
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
SOTAAuthor Commented:
Sorry! If the date set in LTEmailDate = '1/1/2018' (Jan 1, 2018) and I run the SQL statement, LTEmailDate gets set to '7/1/2019' (July 1, 2019)
0
 
SOTAAuthor Commented:
Ah yes!! That could be it!
I will check my code!
Thanks!
0
 
SOTAAuthor Commented:
OK...brilliant!!! That was it! I had a loop in there that ran the code twice. Whew!!! Thanks EXPERTS!!!
0
 
SOTAAuthor Commented:
Ya'll are great to have "out there". :-)
0
 
Scott PletcherSenior DBACommented:
Great, glad we could help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.