Q:

Comparing the year to the year part of a date in the database

I have an employee registration form where the employee adds his details. 
When click on the Submit button I'm adding default holidays to the employee from the back end. I have a table holiday in my database which contains the general holidays for every year.
When the employee registers the holidays for the current year alone should be added to the employee_holiday table.
Can anyone tell me how do I compare the current year with that of the date in holiday table and add it to the employee_holiday table?

A:

Not sure if I understood clearly your problem but as far as MySQL query is concerned you can use this query to select current year's holidays:
SELECT *
FROM holidays 
WHERE date_format(now(), '%Y') = date_format(holiday_date, '%Y');

assuming table holiday has a column called holiday_date as the date of the holidays.

