Dynamic File Name not working correctly

  • I have the following code in the expression for the Connection string property.

    The problem is that the leading zeros for the month and the day are being stripped out.

    @[User::outputFileDir] + "COSDEP"+(DT_WSTR, 4) DATEPART("YYYY", GETDATE()) + (DT_WSTR, 2) DATEPART("MM", GETDATE()) + (DT_WSTR, 2) DATEPART("DD", GETDATE()) +".csv"

     

    For Example for September 5, 2007, The file name is C:\CosDep200795.csv

    How do I get the formula not to drop the leading zeros

     

    Thanks

    KR

  • Found my solution:

     

    Here is the code I replaced to get the date in the format that I wanted, in case anyone is interested:

     

    (DT_WSTR,4)YEAR(GETDATE()) + RIGHT("00" + (DT_WSTR,2)MONTH(getdate()),2) + RIGHT("00" + (DT_WSTR,2)DAY(getdate()),2) +".csv"

     

    KR

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply