4.9 DATEDIFF
@DATEDIFF
calculates the difference between two dates or datetimes, in days or seconds.
Syntax
@DATEDIFF ("difference
",date
,date
)
Examples
- Example 1
-
To calculate the number of days since the beginning of the year
2000
:differential = (@DATEDIFF("DD","2000-01-01",@DATENOW()))
- Example 2
-
To calculate the actual day of the year in the above example (
@DATEDIFF
returns0
for2000-01-01
):todays_day = @COMPUTE(@DATEDIFF("DD","2000-01-01",@DATENOW()))+1)