find difference in dates sql 1

find difference in dates sql

SELECT DATEDIFF(day, date1,date2) AS DateDiff
DATEDIFF accepts three arguments
1- day, month, year etc what form you need difference
2,3- dates 

Here is what the above code is Doing:
1. We are selecting the difference between two dates.
2. We are using the DATEDIFF function to calculate the difference.
3. We are using the day argument to specify that we want the difference in days.
4. We are using the date1 and date2 arguments to specify the two dates.
5. We are using the AS keyword to give the output column an alias of DateDiff.

Similar Posts