On Tuesday 03 December 2002 18:29, James Coates wrote: > Perhaps you could throw a clue my way, in that case.
> I have an actor database (mySQL again) which has actor dates of birth in > 'YYYY-MM-DD' format. I want to be able to query against that ignoring the > year: > > * give me actors who have birthdays in the next five days Assuming the column holding the the birthday is called 'birthday': a) you have to work out the date in 5 days time: DATE_ADD(CURRENT_DATE, INTERVAL 5 DAY) b) You have to transform the birthdays so that they are for the current year (so instead of 1981-04-01 it becomes 2002-04-01) CONCAT(YEAR(CURRENT_DATE), '-', MONTH(birthday), '-', DAYOFMONTH(birthday)) c) Combine both into your query: SELECT *, CONCAT(YEAR(CURRENT_DATE), '-', MONTH(birthday), '-', DAYOFMONTH(birthday)) as current_birthday FROM table WHERE current_birthday >= CURRENT_DATE AND current_birthday <= DATE_ADD(CURRENT_DATE, INTERVAL 5 DAY) ** Untested ** use with extreme caution. > * give me actors whose birthdays fall between two dates (ie: Aries) This one is easy, use the BETWEEN clause in your SELECT statement. Consult manual for details. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Intuition, however illogical, is recognized as a command prerogative. -- Kirk, "Obsession", stardate 3620.7 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php