I have a table which stores information about employees and one of those fields is Date. I want to make a query that returns a count of the number of days they have missed, not including weekends. Date format is '2018-1-1' for example, consecutive days would be '2018-1-2', '2018-1-3', and if next record is '2018-1-5', then count would increase by 1 because 2018-1-4 was a Thursday and they should have a record for that day.
Any ideas on how to best do this?
What I have so far:
SELECT * FROM `time` where name like 'John' AND DayOfWeek(Date) not like 7
and dayofweek(Date) not like 1
ORDER BY `time`.`Date` ASC
This is giving me all of the records for John excluding Saturdays and Sundays. What I want to do now is somehow find gaps between the dates that the records have for workdays. For example, consecutive days would be '2018-1-2', '2018-1-3', and if next record is '2018-1-5', then count would increase by 1 because 2018-1-4 was a Thursday