Jump to content

Recommended Posts

Hey,

 

Here is what I want to do ...

I\'ve got a table with the birthdays (when they were born, year eg 1982).

I wan\'t to select the people who will celebrate their birthday

between tomorrow and 8 days from now ...

 

Is there a way?

Problem is the years are 1982, 1983, ... and not 2003

 

Thx!

Link to comment
https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/
Share on other sites

All u have to do is get the date difference

 

I guess we have discussed about that in one of the postings

 

 

$sql = \"select TO_DAYS(\'$today\')- TO_DAYS(\'$birth_date\')\";

 

and u have to collect all the value which has difference < 8

 

Hope I am clear!!

Link to comment
https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-818
Share on other sites

Ok

 

Now say his b.day is on

 

1982 - 1 - 30

yyyy-mm-dd

 

Now instead o 1982 add the current year

 

if u add 1982 u will get the total date like \"7192\" which is not needed

 

Just subtitue with current year

 

select TO_DAYS(\'2003-1-24\') - TO_DAYS(\'2003-1-30\')

 

This will give \"-6\" so 6 days left for his b.day if u get a +ve value that means his b.day is over.

 

Hoep I am clear!!

Link to comment
https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-825
Share on other sites

Good question

 

Now u should write a bit of coding to check this stuff

 

Now in this case the current month is 12 and we are looking for future b.days so we have to change the year here

 

so if u see the month as \"1\" and the current month as \"12\"

 

increment the year eg 2003 + 1 = 2004

 

if the bithday month is less than the current month increment the year

 

Hope this helps!!

Link to comment
https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-828
Share on other sites

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.