Solved

How can I include today's date in filename .csv when using OUTFILE using MySQL

Posted on 2016-08-11
5
67 Views
Last Modified: 2016-08-11
I need to create export a csv file that should be named with date i.e. file20160811.csv

I have my query.
I tried this:
SET @sql_text = CONCAT("Select * from Table1 into outfile 'C:\desktop\",date_format(NOW(),'%Y%m%d'),".csv'");
PREPARE statement FROM @sql_text;
EXECUTE statement;

I got  error Code 1064, error SQL syntax...

can someone help me to fix this?

Thanks in advance.
0
Comment
Question by:Jerry Seinfield
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Sharath earned 500 total points
ID: 41752878
SET @sql_text=CONCAT("Select * from Table1 into outfile 'C:\\desktop\\",date_format(NOW(),'%Y%m%d'),".csv'");

Open in new window

0
 

Author Comment

by:Jerry Seinfield
ID: 41752908
double slash? Interesting...
0
 
LVL 40

Expert Comment

by:Sharath
ID: 41752963
Did it work? did you try?
0
 

Author Comment

by:Jerry Seinfield
ID: 41752968
It works, thanks, but now my user has denied access. That's another issue.
I appreciate your help.
0
 

Author Closing Comment

by:Jerry Seinfield
ID: 41752972
Thanks for your help
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question