From a date and time field of mysql table we can collect the year part by using the function year(). This will collect the year in YYYY format. We can even calculate the year difference between two columns. Here is the main query to get the year part from mysql date and time field.
The basic query is here
SELECT year(dt2) FROM `dt_tb`
This will collect the year part from the field
For easy understanding we will create one PHP page with this query with all other fields.
The sql query is modified to display all the columns with the years and their difference for easy comparison. Here is the query used.
$query="SELECT dt,dt2,year(dt) as year1,year(dt2)as year2,(year( dt2 ) - year( dt )) as difference FROM `dt_tb`";