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?

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"

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.

Try debugging and watching each variable to see it's state

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

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.