The following code sample helps to find the difference between two dates.
First, we provide the syntax to perform such an operation
DATEDIFF ( datepart , startdate , enddate )
Here are few examples on how ti use the function
SELECT DATEDIFF(day, '1/1/2008' ,getdate()) AS no_of_days
Returns the difference in days from 1st Jan 2008.
SELECT DATEDIFF(month, '1/1/2008' ,getdate()) AS no_of_days
Returns the difference in months from 1st Jan 2008.
SELECT DATEDIFF(year, '1/1/2008' ,getdate()) AS no_of_days
Returns the difference in years from 1st Jan 2008.
|
No responses found. Be the first to respond and make money from revenue sharing program.
|