If you read the documentation for the
DateDiff[
^] function, you will see that the usage is
DATEDIFF ( datepart , startdate , enddate )
If the
StartDate is before the
EndDate, the result will be a positive number.
If the
StartDate occurred after
EndDate, the result will be a negative.
If you always want a positive number, then you use the
Abs[
^] function as outlined by
Patrice
And if you always want a negative number; then you use the
Abs function and multiply by -1.
References:
DATEDIFF (Transact-SQL) - SQL Server | Microsoft Docs[
^]
ABS (Transact-SQL) - SQL Server | Microsoft Docs[
^]