Diffence between two date in sql server
How To Find the Date difference from the current date?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Purushottam RathoreRank #120 · 18.2K reputationPosted Aug 7, 2009, 2:55 AM EDT
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....
Kirtan PatelRank #292 · 8.6K reputationPosted Aug 7, 2009, 3:07 AM EDT
Use GetDate() parameter First
Roei BarRank #1,271 · 1.4K reputationPosted Aug 7, 2009, 3:10 AM EDT