...

View Full Version : Sql query to return date that are not in the format of 1900-00-00



kevinkhan
10-07-2011, 12:45 PM
so far i have this query..


SELECT `dateOfBirth`
FROM `friend_req`
WHERE `dateOfBirth` != '0000-00-00'
AND `dateOfBirth` != '1900'
LIMIT 0 , 30

how do i write this query in such a way that it doesnt pick up dates like 1900-01-04 or 1900-10-01 or 1900-08-28

BubikolRamios
10-07-2011, 02:00 PM
how about:
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_year

Old Pedant
10-07-2011, 08:16 PM
Ummm...Bubikol, the problem is that he foolishly did *NOT* store dateOfBirth as a SQL DATETIME field. Apparently he stored it as VARCHAR. So now he is hosed. He has to use ONLY string manipulation to get his answer.

Kevin: Any chance you can change your field from VARCHAR to DATETIME, so that you *can* use all the very very useful MySQL DATE and TIME functions? Which you can't do, now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum