Apply EXTRACT Function with WHERE Clause in MySQL



With the help of following MySQL query, we can apply EXTRACT() function with WHERE clause on the dates stored in a table.

mysql> Select StudentName,EXTRACT(Year from dateofreg)AS YEAR from testing WHERE StudentName = 'Gaurav';
+-------------+------+
| StudentName | YEAR |
+-------------+------+
| Gaurav      | 2017 |
+-------------+------+
1 row in set (0.00 sec)
Updated on: 2020-02-27T06:34:26+05:30

959 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements