Update date records with dateAdd()

I know I cannont do this with Coldfusion without multiple steps, but I think I should be able to accomplish it with a stored procedure. My question is how?

I have a couple of variables:

@groupID int, // the group identifier
@newdatediff int // the number of days to add

I want to update the different iDate dates using dateAdd() and the newdatediff number. I'm guessing here:

SET iDate = dateAdd([day], @newdatediff, iDate)

I have limited knowledge of how to set it up as you can tell. Any help would be greatly appreciated.

Thanks,
Doug

dBedientAsked:
Who is Participating?
 
adwisemanCommented:
Like this, in a stored procedures I think is what your looking for.
You could also perform this directly using the SQL In this procedure, I recomend writing a Stored Procedure though.

CREATE PROCEDURE
    @groupID int,
    @newdatediff int
AS

UPDATE MyTable
SET iDate = dateadd(day, @newdatediff, iDate)
WHERE groupID = @groupID
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.