1
How do I query for period, day, week, month in Mysql? for example I would like to display data filtered by periods example display data yesterday, last week, two weeks, three weeks, a month ago and so on date in date format 2017-06-21 09:26:31
1
How do I query for period, day, week, month in Mysql? for example I would like to display data filtered by periods example display data yesterday, last week, two weeks, three weeks, a month ago and so on date in date format 2017-06-21 09:26:31
3
There are many ways to do this, see the Mysql documentation for Dates:MYSQL Date and Time Functions.
Examples:
Yesterday:
Select * minhaTabela where Date(Data) = DATE_SUB(CURDATE(),INTERVAL 1 DAY);
or
Select * minhaTabela where Date(DATE_ADD(Data,INTERVAL 1 DAY)) = CURDATE();
Last week:
Select * from minhaTabela where Week(data)+1 = Week(curdate());
...The documentation has several functions and examples.
Browser other questions tagged mysql database select date
You are not signed in. Login or sign up in order to post.
Thank you, it worked perfectly.
– Gabriel José