SQL SSIS Package

In my SQL SSIS package, I have exported some data to file.

I want to export to a file with following filename format: filename_YYYYMMDD_hhmmss.txt

In my expression builder, it type in the following:
"C:\\BlueCreek Files\\Account\\AmesAccount"+"_"+(DT_STR, 50, 1252) Getdate()+".txt"

Result are:

C:\BlueCreek Files\Account\AmesAccount_2018-01-23 13:03:21.122000000.txt

This is close, but how can I get it in the exact format I want?
LVL 1
isamesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
Since you want to exclude the characters '-', space, ':' and milliseconds you need to use scripts like this..

(DT_WSTR,4)YEAR(@[User::InputDate])
+ RIGHT("0" + (DT_WSTR,2)MONTH(@[User::InputDate]), 2)
+ RIGHT("0" + (DT_WSTR,2)DAY(@[User::InputDate]), 2) + "_"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("hh", @[User::InputDate]), 2)
+ RIGHT("0" + (DT_WSTR,2)DATEPART("mi", @[User::InputDate]), 2)
+ RIGHT("0" + (DT_WSTR,2)DATEPART("ss", @[User::InputDate]), 2)
1
isamesAuthor Commented:
I used the following to achieve my goal:


"C:\\directory and FILENAME"+"_"+(DT_WSTR, 4) YEAR( GETDATE() ) +
RIGHT( "0" + (DT_WSTR, 2) MONTH(  GETDATE() ), 2 )  + RIGHT("0" +  (DT_WSTR, 2) DAY(  GETDATE() ), 2 ) +"_"+
REPLACE(SUBSTRING((DT_WSTR,30)GETDATE(),11,9),":","") + ".txt"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isamesAuthor Commented:
THis worked for me
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.