Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Date/Time to File Name in Lotuscript Agent

Status
Not open for further replies.

shadowsanders

IS-IT--Management
Mar 1, 2011
4
US
I need the output file in below to contain a date/time stamp. Can someone please tell me exactly how I need to modify the following to make this happen? Any help would be greatly appreciated.

Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim nbcol As Integer
Dim k As Integer
Dim newline As String
Dim fileName As String
Dim fileNum As Integer
Dim item As NotesItem

Set db = s.CurrentDatabase
Set view = db.GetView( "Send To PI" )
nbcol = Ubound(view.Columns)
Set doc = view.getfirstdocument

fileName = "\\server\lotusdata\filename.csv"
fileNum = Freefile()
Open fileName For Append As fileNum

k = 0
While Not (doc Is Nothing)

newline = ""
For k = 0 To nbcol
newline = newline + doc.ColumnValues(k)
If k <> nbcol Then newline = newline + ","

Next

Print #fileNum, newline
Set doc = view.GetNextDocument(doc)
Wend

Close fileNum


End Sub
 


Dim timestamp As String
timestamp = CStr(Now)

Print #fileNum, timestamp
 
I guess I should have been clearer in my initial post - I need the name of the output file that is created to include the date and time - so if the file was created today it would be named "filename03022011 10:20"

Can you explain to me exactly how I need to alter this code to make that happen?

Thank you so much.
 
If the file doesn't already exist, it will be created when you open it.

The timestamp will contain some characters which aren't allowed in a filename, so you have to remove them before including the timestamp in the filename

Dim fileName As String
Dim timestamp As String
timestamp = CStr(Now)
timestamp = Replace(timestamp, "/", "")
timestamp = Replace(timestamp, ":", "-")
fileName = "c:\temp\AAAAAA_" & timestamp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top