DATEDIFF() Function in SQL Server



The DATEDIFF() function returns the difference between two dates.

  1. SELECT DATEDIFF(year'2010/08/25','2015/08/25'AS DateDiff;  
  2.   
  3. SELECT DATEDIFF(month'2010/08/25 10:40:30','2015/08/25 10:40:30'AS DateDiff;  
  4.   
  5. SELECT DATEDIFF(n, '2010/08/25 10:40:30','2015/08/25 10:40:30'AS DateDiff;  
  6.   
  7. SELECT DATEDIFF(ss, '2010/08/25 10:40:30','2015/08/25 10:40:30'AS DateDiff;  

0 Comment's

Comment Form

Submit Comment