Difference of two date time in sql server

后端 未结 20 2101
心在旅途
心在旅途 2020-12-01 03:53

Is there any way to take the difference between two datetime in sql server?

For example, my dates are

  1. 2010-01-22 15:29:55.090
20条回答
  •  悲哀的现实
    2020-12-01 04:47

    SELECT DATEDIFF(yyyy, '2011/08/25', '2017/08/25') AS DateDiff
    

    It's gives you difference between two dates in Year

    Here (2017-2011)=6 as a result

    Syntax:

    DATEDIFF(interval, date1, date2)
    

提交回复
热议问题