Which of the following statement is correct for DATEDIFF function in SQL? I.…
2024
Which of the following statement is correct for DATEDIFF function in SQL? I. This function reports difference between the arguments ‘startdate’ and ‘enddate’. II. In this, ‘datepart’ argument/value can be specified in a variable.
- A.
Only I
- B.
Neither I nor II
- C.
Both I and II
- D.
Only II
Attempted by 134 students.
Show answer & explanation
Correct answer: A
The SQL `DATEDIFF` function returns the difference between `startdate` and `enddate` for a specified date part. In SQL Server, the `datepart` argument is a keyword, not a variable value. Therefore only statement I is correct.