0

Hi all,

This is something I should know but for some reason the answer is eluding me. In a SSIS Script Task Editor, I am trying to set a package String variable called ReNameFile with the following VB.NET line using DateParts for month and year:

Dts.Variables("User::ReNameFile").Value = Dts.Variables("User::fileName").Value.ToString + DatePart(DateInterval.Month, Date.Now) + DatePart(DateInterval.Year, Date.Now) + ".csv"

This line is not working for me though and I think it's because I am messing up the concatenation of the dateparts. Can someone please guide me here?

3
Contributors
5
Replies
7
Views
4 Years
Discussion Span
Last Post by Stuugie
2

I don't have much experience with VB, but I would try something like this:

Dts.Variables("User::ReNameFile").Value = Dts.Variables("User::fileName").Value.ToString() + DatePart(DateInterval.Month, Now).ToString() + DatePart(DateInterval.Year, Now).ToString() + ".csv"
0

Hi AleMonteiro, I tried your suggestion but it throws errors too. I think I am going to check the my variable fileName to make sure that it has been instantiated. I appreciate your suggestion though and will keep trying.

0

This might be silly, but if it's VB.NET shouldn't you use "&" instead of "+" for concatenation?

0

The error was with the variable fileName that had no value.

@adam k, for whatever reason, the "+" is what works. Not very consistant I know but it is what it is I guess.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.