year fetch problem with mysql ......

From: Date: Mon, 19 May 2003 07:19:28 +0000
Subject: year fetch problem with mysql ......
Groups: php.windows 
Request: Send a blank email to php-windows+get-19999@lists.php.net to get a copy of this message
hay guyz im sorry if this mail is outta list scope..... but nobdy on mysql@lists seem to b able to solve this one as i have been stuck with this silly thing for the last three days n cant find me way outta it the thing is i have to fetch a record set to calculate the age of a child in years i came accross a function at: http://www.mysql.com/doc/en/Date_and_time_functions.html the function being SELECT DATE_FORMAT(NOW(), '%Y') - DATE_FORMAT(dob, '%Y') - (DATE_FORMAT(NOW(), '00-%m-%d') < DATE_FORMAT(dob, '00-%m-%d')) i modified it for myself : SELECT count(distinct tbl_chld_reg_400.chld_id) from tbl_chld_reg_400 where month(tbl_chld_reg_400.dom) = $loop_mon and year(tbl_chld_reg_400.dom) = $yr and ((DATE_FORMAT('tbl_chld_reg_400.dom', '%Y') - DATE_FORMAT('tbl_chld_reg_400.dob', '%Y') - (DATE_FORMAT('tbl_chld_reg_400.dom', '00-%m-%d') < DATE_FORMAT('tbl_chld_reg_400.dob', '00-%m-%d'))) >=1) and ((DATE_FORMAT('tbl_chld_reg_400.dom', '%Y') - DATE_FORMAT('tbl_chld_reg_400.dob', '%Y') - (DATE_FORMAT('tbl_chld_reg_400.dom', '00-%m-%d') < DATE_FORMAT('tbl_chld_reg_400.dob', '00-%m-%d'))) <=5) and tbl_chld_reg_400.gndr='1' and the result is still fetched to be 0 i have made about 6 queries to fix it up n nun of em aint seem to be workin guyz .....what am i screwin here ????? thnx a million toby __________________________________________________ Yahoo! Plus For a better Internet experience http://www.yahoo.co.uk/btoffer

« previous php.windows (#19999) next »