0

I have a source file called venkat_file. I need to archive the file into an archive folder, whilst appending the file to this format, venkat_file_MMDDYYY. If the month and date values are less than 10 I wanted to archive the file with specific values,

Example before: venkat_file, example date 4/26/2013, now I need to archive the file so it looks like this: venkat_file_04262013, instead of venkat_file_4262013.

Thanks in advance,

Venkat.

4

2 回答 2

2

你可以有这样的功能:

Function FormatNum(n, totalDigits) 
  If totalDigits > Len(n) Then 
      FormatNum = String(totalDigits - Len(n),"0") & n 
  Else 
      FormatNum = n 
  End if 
End Function

并像这样使用它:

s = FormatNum(Month(Date()) , 2) & _
    FormatNum(Day(Date()), 2) & _
    Year(Date())
于 2013-04-26T02:52:26.433 回答
0

您可以使用以下附加日期

Dim ThisDate as string
'
ThisDate = format(now.month,"00") &  format(now.day,"00") & format(now.year,"0000")

更新

正如 Raybiss 指出的那样,它不是 vbscript。所以我把vbscript放在下面。

<script type="text/vbscript" id="ArchiveFile">
' <!--
Function GetNewArchiveFilename(ThisFile)
'
Dim ThisDay, ThisMonth, ThisYear
Dim ThisFName
'
  ThisDay = day(date)
  ThisMonth = month(date)
  ThisYear = year(date)
  ThisFName = Left(Thisfile, len(thisfile)-4) & FormatNumber(Thisday,0,-1) & formatnumber(Thismonth,0,-1) & formatnumber(thisyear,0,0,0,0) & right(thisfile,4)
  'msgbox(thisfname)
  return thisfname
'
End Function
' -->
</script>
于 2013-04-26T02:40:52.817 回答