Determine date difference in MS Sql

Language:: T-SQL Type:: Persistence Context:: differences in dates, time-till

Description – Used for getting the time-till or time-since dates

Snippet –

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

Dependencies:: MS Sql

interval

Required. The part to return. Can be one of the following values:

  • year, yyyy, yy = Year
  • quarter, qq, q = Quarter
  • month, mm, m = month
  • dayofyear = Day of the year
  • day, dy, y = Day
  • week, ww, wk = Week
  • weekday, dw, w = Weekday
  • hour, hh = hour
  • minute, mi, n = Minute
  • second, ss, s = Second
  • millisecond, ms = Millisecond

date1, date2

Required. The two dates to calculate the difference between

Type::snippet