Wednesday, March 28, 2012

Renaming a File to include Date and Time

Hi

I am trying to move a flat file to an archive folder and then rename the file to include the date and time of runtime.

I have set up a File System Task to move the file which works fine and a second File System Task to rename. The IsDestinationPathVariable is set to TRUE and the DestinationVariable is called User::Error_Log_File_Rename. There is an expression as follows:

@.[User::Error_Log_File_Rename] = "Y:\\SSIS_PUD_Upload\\Error_Log_Archive\\Update_Error_Messages - " +REPLACE((DT_WSTR, 30)(DT_DBDATE)GETDATE() + "-" + (DT_WSTR, 30)(DT_DBTIME)GETDATE(),":","-") +".txt"

which is the required file name.

If I go into the expression and evaluate it it will give me the current date and time. However when I run it as part of the package say 10 minutes later the file is renamed using the same date and time from 10 minutes before when I evaluated the expression. If I wait another 10 minutes and run the package again it still retains the original date and time.

Is there a way to get the expression evaluated with the current date and time during execution of the package?

Thanks in advance

Scott

Are you using the expression section of the properties for the variable, User::Error_Log_File_Rename? And you have EvaluateAsExpression set to true?|||

Hi Phil

I have the variable in the expression section in the properties but I cannot see a 'EvaluateAsExpression' setting that I can set to true?

Where would i see this?

Thanks

Scott

|||

Racsco wrote:

Hi Phil

I have the variable in the expression section in the properties but I cannot see a 'EvaluateAsExpression' setting that I can set to true?

Where would i see this?

Thanks

Scott

Scott,

Select your variable in the variables panel and press F4. This will bring up the properties panel, displaying the properties of the variable. One of the properties is called EvaluateAsExpression. Set it to TRUE.

-Jamie

No comments:

Post a Comment