How to check for date difference if having clause is not true?

I am filtering a table that has records about Exams. A user can take an exam only 5 times during one year.
How to filter this?
I managed to filter the part with 5 times, but how can I check for date difference if the user has already been to exams for five times.

This is my query so far:
SELECT ClassId,StudentId
FROM Exam
GROUP BY ClassId,StudentId
HAVING Count(Date) <5

I thought I could just use OR DateDIff after the Having, but it must be in the WHERE clause.

Based on your description, it sounds like it should be <= 5 rather than <.

HAVING Count(Date) <= 5 AND DATEDIFF(DAY, MIN(Date), MAX(Date)) ^whatever check you want to do here^

I can't believe it. I tried that, but with a wrong syntax.
Thanks!!