Anuar Maratkhan
Anuar Maratkhan

Reputation: 325

presenting age more than [number] from birth date in sql

I have a table called dependent:

enter image description here

And now I need to present the dependents more than 40 years old for example.

P.S. Right now I am trying to use DATEDIFF(CURDATE(), dependent.bdate)/365.25 function, but still can't present it. How to do this?

Upvotes: 0

Views: 46

Answers (1)

Phil
Phil

Reputation: 164881

Assuming bdate is an actual DATE column, I think it would be easier to create a date 40 years prior to the current date and select where bdate is less-than or equal to that date

WHERE dependent.bdate <= DATE_SUB(CURDATE(), INTERVAL 40 YEAR)

Upvotes: 1

Related Questions