Introduction
This page provides documentation for the datediff
function in the SQL Language Reference.
Function Description
The datediff
function calculates the difference between two dates.
Function Parameters
Parameters:
- date1: The first date. Format: YYYY-MM-DD
- date2: The second date. Format: YYYY-MM-DD
Return Value
Return Type: A number representing the difference in days between the two dates.
Example
Example: Calculate the difference between January 1, 2023, and December 31, 2023.
Result: 365 days
Usage
Syntax: datediff(date1, date2)
Error Handling
The function returns 0 if both dates are the same.
References
Refer to the SQL Language Reference for more details.