Update date records with dateAdd()

Posted on 2006-03-20
Last Modified: 2008-03-03
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.


Question by:dBedient
    1 Comment
    LVL 14

    Accepted Solution

    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.

        @groupID int,
        @newdatediff int

    UPDATE MyTable
    SET iDate = dateadd(day, @newdatediff, iDate)
    WHERE groupID = @groupID

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    The steps for moving the system databases to a new location are documented in the following technical article: However sometimes after the moving process is finished, though SQL i…
    This is my first ever Article on EE or elsewhere; therefore, please bear with me if I have some discrepancies in my writing. I read many articles and questions related to "how to pass values to SSIS packages at run-time?"  Hence, this common ques…
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now