Jump to content

Birthdays Last Week and This Week


bschultz

Recommended Posts

I have a column (DATE) for bithdays...how can I select in MYSQL which birthdays were last week...and the upcoming week?

 

I found this...but it's only for the upcoming week...not last week too...

 

$sql = 'SELECT * FROM table WHERE WEEK(birthdate) = WEEK(DATE_ADD(NOW(), INTERVAL 7 DAY))';

 

How can I adjust this to include last week too?

 

Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/276888-birthdays-last-week-and-this-week/
Share on other sites

$sql = 'SELECT * FROM table WHERE WEEK(birthdate) = WEEK(DATE_ADD(NOW(), INTERVAL 7 DAY)) AND WEEK(birthdate) = WEEK(DATE_ADD(NOW(), INTERVAL -7 DAY))';

 

AND.... OR?

 

This week can't be this week and next week, and even last week can it?

 

I guess it could be this week or next week, or even last week.

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.