It brought back results from other months that occured on the same day.I posted wrong request :( But it can be easily extended to become right:
Rewriting of the request to use DATE_FORMAT can be performed according to the docs.-- today SELECT * from `your_table_name` WHERE YEAR(time) = YEAR(NOW()), DAYOFYEAR(time) = DAYOFYEAR(NOW()) --this month SELECT * from `your_table_name` WHERE YEAR(time) = YEAR(NOW()), MONTH(time) = MONTH(NOW()) --this week (USA) (simple solution with WEEK() --won't work at the beginning of the year SELECT * from `your_table_name` WHERE YEARWEEK(time, 0) = YEARWEEK(NOW(), 0)
I don't know if it's a Perlish way, but it's a RIGHT way. SELECT must select only the data you want, and it's faster and cleaner to perform all heavy-weight data filtering on the database side.
In reply to Re^3: (OT) parsing time in mysql
by Ieronim
in thread (OT) parsing time in mysql
by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |