amolv Posted May 6, 2011 Share Posted May 6, 2011 Hello All, i have dates stored with date data type in mysqladmin, i want last 30 rows between coming Sunday to previous 30 days, i am unable to cal coming Sunday in query i am doing, $query = "select * from table where DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= date ORDER BY date Asc"; here in place of current date i want coming Sunday. Plz help! Quote Link to comment https://forums.phpfreaks.com/topic/235670-get-coming-sunday-date-using-curdate/ Share on other sites More sharing options...
mikosiko Posted May 6, 2011 Share Posted May 6, 2011 one way to solve it: use any of the functions weekday() or dayofweek() reading the description of your issue your select should be something like this: SELECT * FROM table WHERE date_field between (next_sunday - 30 days) and next_sunday ORDER BY date_field DESC LIMIT 30; obviously the challenge for you to work on (using one of the suggested functions) is to get the value of next_sunday and (next_sunday - 30) Quote Link to comment https://forums.phpfreaks.com/topic/235670-get-coming-sunday-date-using-curdate/#findComment-1211436 Share on other sites More sharing options...
amolv Posted May 7, 2011 Author Share Posted May 7, 2011 $comingSundayDate = date('Y-m-d', strtotime('next Sunday')); used in php to get coming sunday curdate in mysql try later .. closing for now. Quote Link to comment https://forums.phpfreaks.com/topic/235670-get-coming-sunday-date-using-curdate/#findComment-1211857 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.