Use the DATEDIFF function to return the number of datepart units between two dates or timestamps. For example, return the number of days between two dates or the number of hours between two timestamps. The result is a number.

The first parameter is the datepart, such as yy for year or month. The second and third parameters are the date or timestamp values to compare.