Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

mysqldump using where clause with current date or date range

mysqldump using where clause with current date or date range

mysqldump using where clause with current date or date range


Anyone can help on how to mysqldump using where clause with date range, i have sql statement but it will not generated an output needed like in "with data :".

table definition : testtab1

field definition :
| uploaded_date | timestamp | NO | | CURRENT_TIMESTAMP

with data :
| uploaded_date |
| 2017-05-05 03:00:15 |
| 2017-05-05 03:00:24 |
| 2017-05-05 03:00:29 |
| 2017-05-05 03:00:33 |
| 2017-05-05 03:00:34 |
| 2017-05-05 03:00:38 |
| 2017-05-05 03:00:43 |
| 2017-05-05 03:00:44 |
| 2017-05-05 03:00:46 |
| 2017-05-05 03:00:50 |
| 2017-05-05 03:01:03 |
| 2017-05-05 03:01:03 |

SQL Statement :

First test : not generating output like "with data :"
# fnow=$(date +"%Y-%m-%d 00:00:00")
# tnow=$(date +"%Y-%m-%d 23:59:59")
# mysqldump -uuatusr01 -puatusr@01 -t -c -n --where="(uploaded_date>='$fnow' and uploaded_date<='$tnow')" uatdb testtab1 > output.sql

Second test : not generating output like "with data :"
# mysqldump -uuatusr01 -puatusr@01 -t -c -n --where="date_format(uploaded_date,'%Y%m%d')=date_for mat(now(),'%Y%m%d')" uatdb testtab1 > output.sql

Thanks in advanced.


RE: mysqldump using where clause with current date or date range

Would not using "into outfile" be simpler?


SELECT 'columns' INTO OUTFILE 'path-to-file.sql' FROM 'table' WHERE criteria; 


Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close