Actually, the code I gave you is not accurate. For example, first_child_birthday = ’12-31-2000′ and second_child_birthday = ’01-01-2003′ would be selected but the difference is actually only 2 years + 1 day.
Here is a query that I think is correct:
SELECT u.*, um1.meta_value as first_birthday, um2.meta_value as second_birthday
,CONCAT(SUBSTR(um1.meta_value,7),'-',SUBSTR(um1.meta_value,1,2),'-',SUBSTR(um1.meta_value,4,2)) AS first_date
,CONCAT(SUBSTR(um2.meta_value,7),'-',SUBSTR(um2.meta_value,1,2),'-',SUBSTR(um2.meta_value,4,2)) AS second_date
,DATEDIFF(CONCAT(SUBSTR(um2.meta_value,7),'-',SUBSTR(um2.meta_value,1,2),'-',SUBSTR(um2.meta_value,4,2))
,CONCAT(SUBSTR(um1.meta_value,7),'-',SUBSTR(um1.meta_value,1,2),'-',SUBSTR(um1.meta_value,4,2))) AS days_diff
FROM $wpdb->users u
JOIN $wpdb->usermeta um1 ON u.ID = um1.user_id
JOIN $wpdb->usermeta um2 ON u.ID = um2.user_id
WHERE um1.meta_key = 'first_child_birthday'
AND um2.meta_key = 'second_child_birthday'
AND DATEDIFF(CONCAT(SUBSTR(um2.meta_value,7),'-',SUBSTR(um2.meta_value,1,2),'-',SUBSTR(um2.meta_value,4,2))
,CONCAT(SUBSTR(um1.meta_value,7),'-',SUBSTR(um1.meta_value,1,2),'-',SUBSTR(um1.meta_value,4,2))) >= 1095
Adding in code for different formats would make this much more complicated.
The best thing you can do is keep all dates in ‘YYYY-MM-DD’ format. That would simplify the sql quite a bit.
If you cannot do that, you must keep all dates in ‘MM-DD-YYYY’ format and use the code above.