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.
Output is 2015
For a invalid date we will get Null as output
Output is NULL
The basic query with MYSQL table 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.