Hello Friends,
Generally we need to do date based search in mysql like Get all the users registered in the last week, or last day, last month, last year. We have very good function of mysql DATE_SUB(). Lets get some the example below:
1) Select * from community where CommuCreateDateTime > DATE_SUB(NOW(), INTERVAL 1 DAY);
2) Select * from community where CommuCreateDateTime > DATE_SUB(NOW(), INTERVAL 1 WEEK);
3) Select * from community where CommuCreateDateTime > DATE_SUB(NOW(), INTERVAL 1 MONTH);
4) Select * from community where CommuCreateDateTime > DATE_SUB(NOW(), INTERVAL 1 YEAR);
5) Select * from oc_order where date_modified < DATE_SUB(NOW(), INTERVAL 1 Hour);
0 Comment(s)