How do I calculate how old a date is or convert a date into a...

Expand / Collapse
 

How do I calculate how old a date is or convert a date into a number?


This can be done by creating a view and using the DATEDIFF function.  Here is a DATEDIFF code sample that will calculate the numerical difference between two dates.

SELECT DATEDIFF(day,OrderDate, GETDATE()) AS DaysOld FROM Orders



Details
Type: FAQ
Options