Setting a variable to an expression

  • I'm trying to use a script to set the value of a variable to an expression. The code I'm using is below. What am I doing wrong?

    Public Sub Main()

    '

    ' Add your code here

    dts.Variables("varCurrentPeriod").Value = (DT_WSTR,4) FLOOR(DATEDIFF("mm", (DT_DATE)"27-Jan-1989",GETDATE()))

    '

    Dts.TaskResult = Dts.Results.Success

    End Sub

  • In your script task, did you set the variable to be read/write?

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • This was removed by the editor as SPAM

  • Wow, that really worked! I've learned more about SSIS 2005 in the past month than in the previous 2 years! Thanks so much!

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

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