I need some help writing a MySQL query to show me rows from last month, but not the whole month, only up and until the same day, hour and minute as it is now(), but 1 month
My solution was to avoid using NOW() when writing sql with your programming language, and substitute with a string. The problem with NOW() as you indicate is it includes current time. So to capture from the beginning of the query day (0 hour and minute) instead of:
r.date <= DATE_SUB(NOW(), INTERVAL 99 DAY)
I did (php):
$current_sql_date = date('Y-m-d 00:00:00');
in the sql:
$sql_x = "r.date <= DATE_SUB('$current_sql_date', INTERVAL 99 DAY)"
With that, you will be retrieving data from midnight of the given day