We help IT Professionals succeed at work.

DTS Run date output to file.

donnie91910
donnie91910 asked
on
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.
Comment
Watch Question

BRONZE EXPERT
Top Expert 2012

Commented:
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

Author

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.
BRONZE EXPERT
Top Expert 2012

Commented:
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.
BRONZE EXPERT
Top Expert 2012
Commented:
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

Explore More ContentExplore courses, solutions, and other research materials related to this topic.