At 19:00 +0200 3/24/02, Okan CIMEN wrote:
>Hello,
>
>I am trying to write a script that creates tables via a cronjob but I want
>to name these tables including the current date as a suffix -like
>transections_20020324- . Does anybody know the SQL statement that entegrates
>the table name with the current date?

If you're trying to do it entirely in SQL, you'll have a difficult time,
because table names must be literals.  You can't construct them using a
function that returns the current date.

Otherwise, the way you construct the table name will depend on the programming
language you're using.  In Perl, you could do something like this:

my ($day, $mon, $year) = (localtime (time ()))[3..5];
my $tbl_name = sprintf ("transactions_%04d%02d%02d", $year+1900, $mon+1, $day);

my $query = ("CREATE TABLE $tbl_name ... rest of definition here...");


>
>I tried to do it by storing the current_date value at a variable and then
>renaming the table with the variable but it did not work.
>
>Any help will be appreciated
>
>Regards
>Okan
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to