Jump to content

How to query birthdays ...


vhkristof

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

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.