January 28, 2010 at 1:06 am
Hello!
I would like to change a variable via Script task in my SSIS package.
The variable is a string type date (Dátum). the value of the variable must be 8 days earlier day in this format: 100120 (2010.01.20 if today is 2010.01.28)
My script is looking this:
Public Sub Main()
'
Dts.Variables("Dátum").Value = Right("0" & Year(Now() - 8), 2) & Right("0" & Month(Now() - 8), 2) & Right("0" & Day(Now() - 8), 2)
'
Dts.TaskResult = Dts.Results.Success
End Sub
My problem is that the Now() - 8 is error.
I can't find any reference for the Visual Basic.NET Thats why I ask you to help my little problem.
Please help me! Thanks
January 28, 2010 at 1:26 am
Try this:
Public Sub Main()
Dts.Variables("Datum").Value = Right("0" & DateAdd(DateInterval.Day, -8, Today).Year, 2) & Right("0" & DateAdd(DateInterval.Day, -8, Today).Month, 2) & Right("0" & DateAdd(DateInterval.Day, -8, Today).Day, 2)
Dts.TaskResult = ScriptResults.Success
End Subb
January 28, 2010 at 1:46 am
Hello!
Thank you very much for the fast help!
It is working correctly.
Do you have a link where I can find some language reference for VB.NET?
January 28, 2010 at 2:00 am
You're welcome.
Can't help you with the link - I'm not a programmer myself :-).
Actually, you do not really need a script task to solve your problem: you can use an Execute SQL Task and do the transformation in T-SQL like this:
SELECT CONVERT(CHAR(6),DATEADD(d,-8,GETDATE()),12)
Set the ResultSet to single row and map the output to your parameter.
Saves you the trouble of learning VB or C# 😀
January 28, 2010 at 2:25 am
Thanks
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply