Thanks to some help I have a MySQL query that starts on 2014-10-10 and fines the amount of holidays in 12 months period eg 2014-10-10 to 2015-10-09 then 2015-10-10 to 2016-10-09
SELECT
e.name AS Employee,
CEIL(DATEDIFF(h.date, e.startdate)/365) as Year,
count(h.date) as Holidays_Taken
FROM employees AS e
LEFT JOIN holidays_taken AS h ON e.id = h.empid
WHERE e.id = 1
GROUP BY Year
With a result
+----------+------+---------------+
| Employee | Year | Holidays_Taken|
+----------+------+---------------+
| Jon | 1 | 5 |
+----------+------+---------------+
| Jon | 2 | 1 |
+----------+------+---------------+
Is it possible to have the year show 2014-10-10 to 2015-10-09 instead of year 1 then 2015-10-10 to 2016-10-09 for year 2
Here's my SQL FIDDLE
Thanks