Jump to content

Birthdays Last Week and This Week


Go to solution Solved by 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.

Edited by l0gic
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.