DATEDIFF returns the difference between two dates.
DATEDIFF( <date-part>, <start-date>, <end-date> )
- Date Part — Determines the type of units to calculate between dates (see below).
- Start Date — The first date in the range.
- End Date — The second date in the range.
- Year — yy (or yyyy)
- Month — m (or mm)
- Week — ww (or wk)
- Hour — hh
- Minute — mi (or n)
- Quarter — q (or qq)
- Day of Year — dy (or y)
- Weekday — w (or dw)
- Day — d (or dd)
How many months since a Participant's last attendance:
This example uses weekday with DATEADD to find the first of the week.
DATEADD(wk, DATEDIFF(wk, 6, GETDATE()), 0)