Diferencia de Fecha SQLSERVER

Para calcular la diferencia entre fechas podemos usar el DateDiff.

DATEDIFF (datepart , startdate , enddate )

En datepart podemos usar:
Year yy, yyyy
quarter qq, q
Month mm, m
dayofyear dy, y
Day dd, d
Week wk, ww
Hour hh
minute mi, n
second ss, s
millisecond ms

Ejemplo:
USE pubs
GO
SELECT DATEDIFF(day, pubdate, getdate()) AS date FROM titles

GO


Fuente:http://www.mistrucos.net/truco-sql-server-calcular-diferencia-fechas-419.htm
Espero que les haya servido
Saludos
Adalberto Montanía

Comentarios