Adding a timestamp to a filename

K

kbrad

I am uploading files to my webserver using an asp upload script and would
like to add a timestamp just before they are saved to the server.
This would mean that filename.txt on my server would be uploaded to the
webserver as filenameYYMMDDhhmmss.txt or something similar.
Can anyone advise how to do this?
 
A

Aaron [SQL Server MVP]

I am uploading files to my webserver using an asp upload script and would
like to add a timestamp just before they are saved to the server.
This would mean that filename.txt on my server would be uploaded to the
webserver as filenameYYMMDDhhmmss.txt or something similar.
Can anyone advise how to do this?

Most likely, depends on what upload component you are using. Several have a
SaveAs method or something equivalent.
 
A

Andrew Zamkovoy

Hello,

If your file name 100% has file extension:

Get file extension:
Response.Write UBound (Split (LCase ("filename.com.txt"), ".", -1, 1))

Get date/time stamp:
N = Now
Response.Write Right ("0" & Year (N), 4) & Right ("0" & Month (N), 2) &
Right ("0" & Day (N), 2) & "_" & Right ("0" & Hour (N), 2) & Right ("0" &
Minute (N), 2) & Right ("0" & Second(Now), 2)

Or, simple rename file later, after upload. Do upload in some temporarely
folder (by date/time), then rename file.

With best regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top