title: MySQL event .csv outputfile with timestamp in name
body: <p>i have a MySQL database with 3 tables (log data). Each table gots the same structure.</p>
  
  <p>Now i want to write an event that runs every 6 months and exports all rows in a csv file, who are older than a half year and delete them in the second. The filname should include the timestamp of export.</p>
  
  <p>In the beginning i tried to export a table with a static name - that works well (here with smaller time intervalls for testing):</p>
  
  <pre><code>CREATE EVENT exportLog
  ON SCHEDULE
  EVERY 1 MINUTE
  DO
  SELECT *
  INTO OUTFILE 'C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/exporttest.csv'
  FIELDS TERMINATED BY ','
  ENCLOSED BY '"'
  ESCAPED BY '\\'
  LINES TERMINATED BY '\n'
  FROM mytable WHERE timestamp &lt; (NOW() - INTERVAL 5 DAY)
  </code></pre>
  
  <p>Now i try to handle this with a dynamic filename including the timestamp of export. So, that also the older file will never be overwritten. But this doesnt work. Can somebody help?</p>
  
  <pre><code>CREATE EVENT exportLog
  ON SCHEDULE
  EVERY 1 MINUTE
  DO
  BEGIN
  SET @sql_stmt := concat("SELECT * FROM logtable INTO OUTFILE 'C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/export_", DATE_FORMAT(now(),'%Y-%m-%d %H%i%s'),".csv'");
  PREPARE extrct FROM @sql_stmt;
  EXECUTE extrct;
  DEALLOCATE PREPARE extrct;
  END $$
  DELIMITER;
  </code></pre>
  
  <p>Thanks for help!</p>