DTS Run date output to file.

Is there a way to have the [DATE] function in DTSRun to only give me the month?

I need to have the [DATE] function in DTSRun to give me the the month only.
What I have is this:
DTSRun /S [SRVR] /E /N "_Common_FTPUtility" /A INIServer:8:S[SRVR] /A ReportName:8:="Exception_Report" /A SourceFileName:8:="Exception_Report.xls" /A DestFileName:8:="Exception_Report_[DATE].xls"

And this will give me: Exception_Report_20080125.xls

What I want is: Exception_Report_01.xls

thanks.
donnie91910Asked:
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.

Anthony PerkinsCommented:
You will have to modify your DTS Package to add an ActiveX Script Task at the start of the workflow that will assign the value of the DestFileName Global Variable as in:

Function Main()
CONST DESTFILENAME = "Exception_Report_[DATE].xls"
Dim Today

Today = CStr(Year(Date())) & Right("0" & CStr(Month(Date())), 2) & Right("0" & CStr(Day(Date())), 2)
DTSGlobalVariables("DestFileName").Value = Replace(DESTFILENAME, "[DATE]", Today)

Main = DTSTaskExecResult_Success
End Function

0
donnie91910Author Commented:
I added the code as a vbscript task to the beginning of the dts package and the date on the file did not change.
0
Anthony PerkinsCommented:
Of course it did not.  Since you were passing in a global variable I assumed you were already doing that.  All that code does is assign the date to the global variable.

Since what you are now asking bares little resemblance to the original question, why don't you go ahead and describe the DTS package and which connection you are trying to change.
0
Anthony PerkinsCommented:
Also, since you only want Exception_Report_MM.xls,  my function should have been simplified as follows:

Function Main()
CONST DESTFILENAME = "Exception_Report_[DATE].xls"

DTSGlobalVariables("DestFileName").Value = Replace(DESTFILENAME, "[DATE]", Right("0" & CStr(Month(Date())), 2) )

Main = DTSTaskExecResult_Success
End Function
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
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
Microsoft SQL Server

From novice to tech pro — start learning today.