How to apply EXTRACT() function with WHERE Clause on the dates stored in MySQL table?


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: 27-Feb-2020

685 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements