Solved

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

Posted on 2016-08-11
5
57 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

Title # Comments Views Activity
html input clean up 3 53
MySQL left join performance 4 38
Have issues with Query MySQL 9 64
RDBMS and No sql database 4 56
More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now