Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread How To Include The Current Date In A Table Name
Mon, Feb 27 2006 11:11 AMPermanent Link

Andrew Myles
Hi,

I am struggling with what command I need to use to include the current date in the name of a table generated from the INTO command which I then
need to export.

After making the SELECT command I have the following line:

     INTO "P:\My Folder\SQL\My Table - DD-MM-YY" <--- I want Day-Month-Year here!

I then have FROM, WHERE, GROUP BY, HAVING, ORDER BY commands and the statement finishes with:

     EXPORT TABLE "P:\My Folder\SQL\My Table - DD-MM-YY" To "P:\My Folder\My Table -  DD-MM-YY.csv" WITH HEADERS

Any help as to how I go about including the date in my file name would be greatly appreciated!

Thanks

Andrew

Mon, Feb 27 2006 11:40 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Andrew


I'd suggest a string replace.

Roy Lambert
Mon, Feb 27 2006 12:01 PMPermanent Link

Andrew Myles
Roy Lambert <roy.lambert@skynet.co.uk> wrote:

I'd suggest a string replace.

Thanks for a quick response Roy!

Could you enlighten me a little more as to how I would go about using the String Replace in this situation.

I am somewhat of a noob to SQL!!

Thanks

Andrew




Mon, Feb 27 2006 12:51 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Andrew


1. create the sql statement and before executing it
2. DBISAMQuery1.SQL.Text := StringReplace(DBISAMQuery1.SQL.Text,'DD-MM-YY',whatever date you want as a string, [rfReplaceAll]);
3. execute the sql

Roy Lambert
Mon, Feb 27 2006 12:58 PMPermanent Link

Andrew Myles
So that will automatically include the current date in my table name??

It looks to me as though I'd have to type the date in everytime I wanted it to change it.. I want it to pull the current date from the system...
Mon, Feb 27 2006 1:02 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Andrew


"whatever date you want as a string" could be DateToStr(Now) ie anything that returns a string. You could equally well use Format

Roy Lambert
Mon, Feb 27 2006 1:06 PMPermanent Link

Andrew Myles
Ahhhh right i'm with you!

I'll give it a try tomorrow!

Thanks for all your help Roy!
Image