Monday, March 26, 2012

Need Expression Help with DateTime Variable

Hello,

I have a DateTime variable called CurrentDate that needs to reflect the current date, but the date portion only. I checked several functions in the Expression Builder to use with GETDATE() so that I could just get the date portion, but I didn't see anything that really fit. In a SQL query I would normally use CONVERT to do this.

Any ideas?

Thank you for your help!

cdun2

Why do you care if it has a time portion on it?

How are you populating the variable? It'll have to be a string type in order to eliminate the time component.|||

Sorry for the confusion. Actually, the date does need to be cast to a string. I need to append the date to another package variable to complete the 'name' of a flat file. The idea is that when the package runs, the flat file destination file name will contain the current date.

I know how to set up an exression for the 'Name' of the flat file, but what would be the best way to take the result of GETDATE(), cast it to a string, and parse out just the date portion? Since I don't want the non alpha numeric characters in the string, maybe I should just put a date string together using YEAR(GETDATE()) + MONTH(GETDATE()) + DAY(GETDATE()).

If I go this route, how do I used type casting with these date functions?

Thanks again.

|||

Here is my first idea. This would be the expression for the Name property of the flat file Connection Manager;

@.[User::FilePath] + @.[User::FilePrefix] + (DT_STR, 4, 1252) YEAR(GETDATE()) + (DT_STR,2, 1252)MONTH(GETDATE()) + (DT_STR, 2,1252)DAY(GETDATE())

|||

cdun2 wrote:

Here is my first idea. This would be the expression for the Name property of the flat file Connection Manager;

@.[User::FilePath] + @.[User::FilePrefix] + (DT_STR, 4, 1252) YEAR(GETDATE()) + (DT_STR,2, 1252)MONTH(GETDATE()) + (DT_STR, 2,1252)DAY(GETDATE())

I like this idea.

No comments:

Post a Comment