DATEDIFF returns the difference between two dates.
Syntax
DATEDIFF( <date-part>, <start-date>, <end-date> )
Details
- 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.
Date Parts
- 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)
Examples
How many months since a Participant's last attendance:
DATEDIFF(mm,[_Last_Attendance_Date],GETDATE())
This example uses weekday with DATEADD to find the first of the week.
DATEADD(wk, DATEDIFF(wk, 6, GETDATE()), 0)
Resources
View Examples