Diffence between two date in sql server
How To Find the Date difference from the current date?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Roei BarPosted Aug 7, 2009, 7:10 AM
Kirtan PatelPosted Aug 7, 2009, 7:07 AM
Use GetDate() parameter First
Purushottam RathorePosted Aug 7, 2009, 6:55 AM
select top 1 CreatedDate, GETDATE() AS 'Current Date', Datediff (day, CreatedDate, GETDATE()) As 'age difference in day' from tablename
select top 1 CreatedDate, GETDATE() AS 'Current Date', Datediff (month, CreatedDate, GETDATE()) As 'age difference in month' from tablename
select top 1 CreatedDate, GETDATE() AS 'Current Date', Datediff (year, CreatedDate, GETDATE()) As 'age difference in year' from tablename
but I am not getting correct difference....