vhkristof Posted March 27, 2003 Share Posted March 27, 2003 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! Quote Link to comment https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/ Share on other sites More sharing options...
shivabharat Posted March 27, 2003 Share Posted March 27, 2003 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!! Quote Link to comment https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-818 Share on other sites More sharing options...
vhkristof Posted March 28, 2003 Author Share Posted March 28, 2003 but the year is 1982, 1983, ... Quote Link to comment https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-821 Share on other sites More sharing options...
pallevillesen Posted March 28, 2003 Share Posted March 28, 2003 So what ? You should just extract the day and month (probably getting dayofyear is best)... then if ($birthday_dayofyear-$today_dayofyear < { ... } I\'m not sure what will happen around december 24th and forward.... P. Quote Link to comment https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-822 Share on other sites More sharing options...
pallevillesen Posted March 28, 2003 Share Posted March 28, 2003 Again - as in another topic... check the date() function in php... P. Quote Link to comment https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-823 Share on other sites More sharing options...
vhkristof Posted March 28, 2003 Author Share Posted March 28, 2003 Concerning the change of year (2003-2004), would it work completely if I queried a UNIX timestamp? thx for the replys, really appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-824 Share on other sites More sharing options...
shivabharat Posted March 28, 2003 Share Posted March 28, 2003 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!! Quote Link to comment https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-825 Share on other sites More sharing options...
vhkristof Posted March 28, 2003 Author Share Posted March 28, 2003 but when the birthday is on 1 january and i query the db on 31 december ? Quote Link to comment https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-827 Share on other sites More sharing options...
shivabharat Posted March 28, 2003 Share Posted March 28, 2003 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!! Quote Link to comment https://forums.phpfreaks.com/topic/274-how-to-query-birthdays/#findComment-828 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.