-4
SELECT birthday
FROM employees
WHERE ((DATEDIFF(Year,birthday())>'18')
GMB
  • 216,147
  • 25
  • 84
  • 135
  • `birthday` is a column, not a function. `DATEDIFF` has 3 arguments, not 2. – Akina Oct 27 '20 at 12:08
  • You should provide the error or unexpected behaviour you are having. The structure for the table would also help. – madtyn Oct 27 '20 at 12:12
  • @madtyn The deletion has already succeeded, but it deletes the unit value even though there are several employees who have 18 years of age Do you have an idea of the error? – Johne right Oct 27 '20 at 12:20

2 Answers2

1

You can use date arithmetics:

select * from employee where birthdate + interval 18 year <= current_date

This filters out employees that are 18 years old or more as of today.

GMB
  • 216,147
  • 25
  • 84
  • 135
0

You can use DATE_SUB function:

SELECT birthday
FROM employees
WHERE birthday < DATE_SUB(curdate(), interval 18 year);

SQLize.online

Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39