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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to create filename including date/time

Status
Not open for further replies.

compuserf

Technical User
May 8, 2004
2
GB
Apologies if this is an old one. I'm modifying a Paradox 10 form. At present the operator can click a button to export data to a new file on a blank floppy, and this has a fixed filename like JobsDone.db. Now we want it to write the file with a name generated at runtime like JobsDone200405251645.db so it can be emailed for merging elsewhere. Ideally it needs to be more user proof than the present method. Any unique filename will do but it helps if it's visibly chronologically numbered.

I am writing in Paradox 10 on Win2000 but the operator has the runtime program on Win98.

Any advice, pointers to code snippets? Even rtfm is fine if you say which bit.
 
compuserf,

How about something like JobsDone_Date_Time, where _Date might be something like 20040510 (e.g. today's date as an Integer) and _time might be something along the lines of 152320 (HHMMSS)?

If that works for you, then consider the following code sample that generates a string with that value:

Code:
var
   strFilename String
endVar

   strFileName = "JobsDone" + 
      format( "do(%y%m%d),dy3,dm2,dd2", date() ) + 
      format( "to(%h%m%s)", time() ) + 
      ".txt" 

   strFileName.view()

If you run this, you'll get a small window with a value like JobsDone20040510152957.txt.

Be sure to type the format specifiers as letters, not numbers. That is, type "dee-oh" and "tee-oh," not "dee-zero" or "tee-zero."

To use this, simply add it to the code you're already using to export the table.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top