Jump to content

get coming sunday date using CURDATE()


amolv

Recommended Posts

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!

 

Link to comment
https://forums.phpfreaks.com/topic/235670-get-coming-sunday-date-using-curdate/
Share on other sites

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.