469,271 Members | 1,017 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Creating Text File

I'm using ASP 3.0. I'm taking form contents and dumping it into a text file
on the server.
My question is how to add the TIME to this statement. I create the text file
with the name of file, month, day and year.
I would like to add TIME to it.
-------------------------------------------------------------
set fso = createobject("scripting.filesystemobject")

Set act = fso.CreateTextFile(server.mappath("/data/"&g_filename & "-"&
month(date())& day(date())& year(date()) &".htm"), true)
-------------------------------------------------------------
Thank you,

Erik
Jul 19 '05 #1
5 3174
look at Now()
perhaps (not sure) Time() as well

--
----------------------------------------------------------
Curt Christianson (Software_AT_Darkfalz.Com)
Owner/Lead Designer, DF-Software
http://www.Darkfalz.com
---------------------------------------------------------
...Offering free scripts & code snippits for everyone...
---------------------------------------------------------
"Erik" <ER*******@pacificdesignstudios.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
I'm using ASP 3.0. I'm taking form contents and dumping it into a text file on the server.
My question is how to add the TIME to this statement. I create the text file with the name of file, month, day and year.
I would like to add TIME to it.
-------------------------------------------------------------
set fso = createobject("scripting.filesystemobject")

Set act = fso.CreateTextFile(server.mappath("/data/"&g_filename & "-"&
month(date())& day(date())& year(date()) &".htm"), true)
-------------------------------------------------------------
Thank you,

Erik

Jul 19 '05 #2
I tried it already and the error I receive is that it is not part of the
mappath property.

Thanks.

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
look at Now()
perhaps (not sure) Time() as well

--
----------------------------------------------------------
Curt Christianson (Software_AT_Darkfalz.Com)
Owner/Lead Designer, DF-Software
http://www.Darkfalz.com
---------------------------------------------------------
..Offering free scripts & code snippits for everyone...
---------------------------------------------------------
"Erik" <ER*******@pacificdesignstudios.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
I'm using ASP 3.0. I'm taking form contents and dumping it into a text

file
on the server.
My question is how to add the TIME to this statement. I create the text

file
with the name of file, month, day and year.
I would like to add TIME to it.
-------------------------------------------------------------
set fso = createobject("scripting.filesystemobject")

Set act = fso.CreateTextFile(server.mappath("/data/"&g_filename & "-"&
month(date())& day(date())& year(date()) &".htm"), true)
-------------------------------------------------------------
Thank you,

Erik


Jul 19 '05 #3
Function GetFileStamp()
Dim ary1(5)
ary1(0) = Year(Date)
ary1(1) = Pad(Month(Date))
ary1(2) = Pad(Day(Date))
ary1(3) = Pad(Hour(Now()))
ary1(4) = Pad(Minute(Now()))
ary1(5) = Pad(Second(Now()))
GetFileStamp = Join(ary1,"")
End Function
Function Pad(strData)
Pad = Trim(strData)
If Len(Pad) = 1 Then
Pad = "0" & Pad
End If
End Function
dlbjr

Unambit from meager knowledge of inane others,
engender uncharted sagacity.
Jul 19 '05 #4
The probable reason you get the error, and the reason dlbjr's code would
work, is that Time values include colons (:) which can't be used in a
Windows filename.

The other possible cause is that you typed something wrong, or put the Now()
function in the wrong part of your concatenation mess. In this case,
dlbjr's function still makes sense because 1) it makes your code easier to
read and 2) it makes your code easier to reuse.
"Erik" <ER*******@pacificdesignstudios.com> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
I tried it already and the error I receive is that it is not part of the
mappath property.

Thanks.

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
look at Now()
perhaps (not sure) Time() as well

--
----------------------------------------------------------
Curt Christianson (Software_AT_Darkfalz.Com)
Owner/Lead Designer, DF-Software
http://www.Darkfalz.com
---------------------------------------------------------
..Offering free scripts & code snippits for everyone...
---------------------------------------------------------
"Erik" <ER*******@pacificdesignstudios.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
I'm using ASP 3.0. I'm taking form contents and dumping it into a text

file
on the server.
My question is how to add the TIME to this statement. I create the
text file
with the name of file, month, day and year.
I would like to add TIME to it.
-------------------------------------------------------------
set fso = createobject("scripting.filesystemobject")

Set act = fso.CreateTextFile(server.mappath("/data/"&g_filename & "-"&
month(date())& day(date())& year(date()) &".htm"), true)
-------------------------------------------------------------
Thank you,

Erik



Jul 19 '05 #5
"Erik" <ER*******@pacificdesignstudios.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
I'm using ASP 3.0. I'm taking form contents and dumping it into a text file on the server.
My question is how to add the TIME to this statement. I create the text file with the name of file, month, day and year.
I would like to add TIME to it.
-------------------------------------------------------------
set fso = createobject("scripting.filesystemobject")

Set act = fso.CreateTextFile(server.mappath("/data/"&g_filename & "-"&
month(date())& day(date())& year(date()) &".htm"), true)
-------------------------------------------------------------
Thank you,

Erik

Here's how I create a timestamp vbscript:

'*
'* Generate Timestamp (ccyymmddhhnnss)
'*
Dim strNOW
strNOW = Now()
Dim arrNOW(5)
arrNOW(0) = DatePart("yyyy", strNOW)
arrNOW(1) = DatePart("m", strNOW)
arrNOW(2) = DatePart("d", strNOW)
arrNOW(3) = DatePart("h", strNOW)
arrNOW(4) = DatePart("n", strNOW)
arrNOW(5) = DatePart("s", strNOW)
Dim intNOW
strNOW = ""
For intNOW = 0 To UBound(arrNOW)
If (arrNOW(intNOW) <= 9) Then arrNOW(intNOW) = "0" & arrNOW(intNOW)
strNOW = strNOW & arrNOW(intNOW)
Next

Thus, you would use:

Set act = fso.CreateTextFile(server.mappath("/data/" & g_filename & "-" &
strNOW & ".htm"), true)

You had "mmddyy" but I prefer this format which allows multiple files to be
sorted chronologically.

Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Maziar Aflatoun | last post: by
12 posts views Thread by Mats Lycken | last post: by
15 posts views Thread by David Thielen | last post: by
4 posts views Thread by tshad | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.