I have a table:
ID Timestamp
1 2010-07-27 13:14:00.000
2 2010-08-13 13:14:00.000
3 2010-12-21 13:14:00.000
Now I need to subtract the day from Timestamp column with current getdate() and get the days from it.
You can use DATEDIFF
SELECT DATEDIFF(day, Timestamp, getdate())
FROM YourTable
DATEDIFF
Returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.
Syntax
DATEDIFF ( datepart , startdate , enddate )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With