Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert date to string problem

Status
Not open for further replies.

jpicks

MIS
Oct 11, 2002
158
US
I am trying to include the date in the filename of a file that I am copying. I am having problems converting the date to a string and then concatenating it into the filename. The vbscript is running in an ActiveX script in a DTS package.

I've included the code that I have been using.

In my main method:
Code:
strToUploadDir = "C:\TEMP"
strUploadedDir = "C:\TEMP\COPY"
strCurDate = Cstr(date())

Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists(strToUploadDir & "\upload.txt") then
	fso.copyfile strToUploadDir & "\upload.txt", strUploadedDir & "\uploaded" & strCurDate & " .txt" 
	Main = DTSTaskExecResult_Success
Else 
	Main = DTSTaskExecResult_Failure 
End if

I am recieving the following errors:
Error Code: 0
Error Description: Path not found.

Thanks in advance for your help

-Jim
 
you are adding to your path w/ cDate....
ie - strUploadedDir = "C:\TEMP\COPY\6/12/2002"...

I suggest you use this:

strYear = datePart ("yyyy", date())
strMon = datePart ("m", date())
strDay = datePart ("d", date())

if len(strMon) = 1 THEN strMon = "0" & strMon
if len(strDay) = 1 THEN strDay = "0" & strDay

strCurDat = strYear & strMon & strDay
 
mwolf00,

Thanks for your reply. I'm sure that your suggestion will work fine.

-Jim
 
alternatively you can do the following

strCurDate = Left(date(),2) & Mid(Date(),4,2) & Right(Date(),2) Regards
Steve Friday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top