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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Script Problem

Status
Not open for further replies.

itsmarkdavies

Programmer
May 22, 2001
87
GB
I am running an VBScript ActiveX script from a SQL Server 2000 Job Step. The Job runs fine and reports success, but the file I am trying to move does NOT move. Can anyone spot a flaw in my Script ?. Any ideas much appreciated.

Script is as follows :-

Function STAMP
STAMP = FormatDateTime(Date, 1)
Call Archive "\\SERVER1\c$\bills.txt"
End Function

Function Archive(filespec)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

If (fso.FileExists(filespec)) Then

fso.MoveFile filespec, "\\SERVER1\c$\archive\bills"
& STAMP & ".txt"

End If

Set fso = Nothing
End Function itsmarkdavies@hotmail.com
 
When using the FormatDateTime function, the 2nd parameter
tells which date format to use. Format 1 is the long date defined on the computer's regional settings. Very likely, the long date format has slashes, hyphens, colons, etc. You should change the code to create a proper date string for the file name.

See the following links for a couple of ideas on how to format dates in VB script.

If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Thanks Terry, that was it.
I split the date and time up and formatted each segment individually, then re-combined them into a string and it works perfectly.

Cheers. itsmarkdavies@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top