Jump to content

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.