Click to See Complete Forum and Search --> : TimeStamp feature in an ASP page


enigmaos
September 28th, 2001, 07:47 AM
Here's the problem:

I have created an ASP listener page that would save every incoming package into a file on the local IIS/Server with a generic name, but the files cannot have the same name because that would overwrite the preivous file. The code is in the ASP file - VBSript.


'Here's the code:

set xmlDoc = Server.CreateObject("MSXML.DOMDocument")
xmlDoc.Save(Server.mappath("TEST.xml"))

'I have tried to "TimeStamp" the file, but I kept getting error messages - it doesn't recognize "NOW":
TimeStamp = Now()
xmlDoc.Save(Server.mappath(TimeStamp & ".xml"))




Any suggestions?

THANKS!!!

enigmaos@yahoo.com

Cakkie
September 28th, 2001, 08:00 AM
Hmm, normally Now should work in ASP/VBScript. Another thing that could be causing this problem is that now returns a date, which typically includes / in it. This could cause the save function to fail, because / is a path seperator on the web.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

enigmaos
September 28th, 2001, 08:04 AM
is there any other way to save the files with unique names? I guess TimeStamp doesn't work in this case.


enigmaos@yahoo.com

Cakkie
September 28th, 2001, 08:30 AM
Ok, this looks a bit messy (ok, it is a bit messy), it gets the different parts of the date, and adds timer (milliseconds since midnight)

dim timestamp
timestamp = datepart("yyyy",now)
If len(datepart("m",now))=1 then timestamp = timestamp & "0"
timestamp = timestamp & datepart("m",now)
If len(datepart("d",now))=1 then timestamp = timestamp & "0"
timestamp = timestamp & datepart("d",now)
timestamp = timestamp & "-" & (Timer * 100)




Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

enigmaos
September 28th, 2001, 08:57 AM
Thanks much! It works very well! :)

enigmaos@yahoo.com