getdate parameter in execute command

  • Hi all,

    When I execute my store procedure with

    EXECUTE dbo.myStoreProcedure @myParameter = 'my date'

    Its works, but If I want to make :

    EXECUTE dbo.myStoreProcedure @myParameter = DATEADD(day, 2, getdate())

    I have this message  :

    Msg 102, Level 15, State 1, Line 3

    Syntaxe incorrecte vers 'day'.

     


    Kindest Regards,

    degrem_m
    Degremont

  • Try DATEADD(dd, 2, getdate()),

    I cannot test, but often times passing a value to a parameter using a function fails.

     

    you may need to do

     

    declare @date datetime

    set @date = DATEADD(dd, 2, getdate())

    execute dbo.myprocedure @myParameter = @Date

     

  • DATEADD("day", 2, getdate()),

    should work as well.

  • if you assign the value to date first:

    ie..

    @date = Getdate()

    DATEADD(day,2,@date)

    this should work.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply