From: Peter Brawley Date: May 8 2006 3:36pm Subject: Re: [Fwd: Getting next birthdays] List-Archive: http://lists.mysql.com/mysql/197740 Message-Id: <445F6574.1040003@earthlink.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit > I need the birthdays from yesterday, today and the next 4 or 5 birthdays. You don;t need to manually compute every date component. Try something like ... SELECT ... WHERE DATE_SUB(NOW(),INTERVAL 1 DAY) <= mem.birthday AND DATE_ADD(NOW(),INTERVAL 5 DAY) >= mem.birthday ORDER BY mem.birthday; PB ----- ESV Media GmbH wrote: > Hey, i´ve a problem with getting the next and the actual birthdays. > > This my actual birthday sql : > > SELECT SQL_CACHE birthday,mem.lname, mem.fname,mem.mem_id FROM members > mem > INNER JOIN network net ON (net.mem_id = mem.mem_id AND net.frd_id =1) > WHERE > (( DAYOFYEAR(FROM_UNIXTIME( mem.birthday )) < DAYOFYEAR(now()) > )*DAYOFYEAR(CONCAT(YEAR(NOW()),'-12-31')))+DAYOFYEAR(FROM_UNIXTIME( > mem.birthday )) >= DAYOFYEAR(now()) > ORDER BY (( DAYOFYEAR(FROM_UNIXTIME( mem.birthday )) )*DAYOFYEAR(CONCAT(YEAR(NOW()),'-12-31')))+DAYOFYEAR(FROM_UNIXTIME( > mem.birthday )) LIMIT 4 > > The field birthday is in a Unix timestamp format. > I need the birthdays from yesterday, today and the next 4 or 5 birthdays. > And i need the table network to get my friends list. > > > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.392 / Virus Database: 268.5.5/333 - Release Date: 5/5/2006