We help IT Professionals succeed at work.
Get Started

Problem with VB Script

Aleks
Aleks asked
on
149 Views
Last Modified: 2015-07-27
I have a script that should rename a file I uploaded. Goes like this:

If (CStr(Request.QueryString("GP_upload")) <> "") Then
  Dim REUF_renameMask
  Dim sTS
  sTS=sTimeStamp
  REUF_renameMask = DoTrim(Session("FirmId"),2)+"_"+DoTrim(Session("QnrId"),2)+ "_"+sTS+"_"+"##name##"+".##ext##"
  RenameUploadedFiles pau_thePath, pau_nameConflict, REUF_renameMask
end if

--

All of it works fine other than the sTS portion of it which should add the time stamp. Here is my script for it, which works just fine. Only the timestamp for some reason is not being added. Perhaps the syntax in the rename mask is incorrect?

-- This works fine --

Function GetMmDdYyyyHhMmSs(sDate)
      GetMmDdYyyyHhMmSs=""
      If sDate="" OR IsNull(sDate) OR IsEmpty(sDate) Then Exit Function
      If Not IsDate(sDate) Then Exit Function
      Dim sRetVal,sVal
      sRetVal=""
      sVal=DatePart("m",sDate)
      If Len(sVal)=2 Then sRetVal=sVal Else sRetVal="0"&sVal End If
      sVal=DatePart("d",sDate)
      If Len(sVal)=2 Then sRetVal=sRetVal&sVal Else sRetVal=sRetVal&"0"&sVal End If
      sRetVal=sRetVal&DatePart("yyyy",sDate)
      sVal=DatePart("h",sDate)
      If Len(sVal)=2 Then sRetVal=sRetVal&sVal Else sRetVal=sRetVal&"0"&sVal End If
      sVal=DatePart("n",sDate)
      If Len(sVal)=2 Then sRetVal=sRetVal&sVal Else sRetVal=sRetVal&"0"&sVal End If
      sVal=DatePart("s",sDate)
      If Len(sVal)=2 Then sRetVal=sRetVal&sVal Else sRetVal=sRetVal&"0"&sVal End If
      GetMmDdYyyyHhMmSs=sRetVal
End Function
Dim sOldFileName,sNewFileName,sTimeStamp,oFSO
sTimeStamp=GetMmDdYyyyHhMmSs(Now)
Session("attchfilename")=""
Comment
Watch Question
Web Ninja at large
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 15 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE