Hi, > I got a small problem I like to be able to read a DATE but I don't want to > read the Year. I only want to read the month and the date. For example, I > like to read the a Birthday Field to see who Bithday is today. > Also like to > be later be able to read that same field but this time the year so that I > can see how old a person is. Is there any example on the net of this?
I think what you really want is the following functions: * DAYOFMONTH() * MONTH() * YEAR() They all take as an argument a date field and return the appropriate part of the date. There are similar functions for hours, mins, secs, etc. See this section of the manual for more info: http://www.mysql.com/doc/D/a/Date_and_time_functions.html So, using your example of finding all records with date of birth the same as today, regardless of year, we would issue a query like this: SELECT dob FROM yourtable WHERE MONTH(dob) = MONTH(NOW()) AND DAYOFMONTH(dob) = DAYOFMONTH(NOW()); And, to see how old a person is, given their date of birth, you would do something like this: SELECT YEAR(NOW() - YEAR(dob) AS age FROM yourtable; Hope this helps. Regards, Basil Hussain --------------------------------------- Internet Developer, Kodak Weddings E-Mail: [EMAIL PROTECTED] --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php