Sql Server: Get number of days between two dates - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial

Sql Server: Get number of days between two dates

In this article I am going to explain how to get number of days between two dates in Sql server.



Implementation:

DATEDIFF() function of Sql server returns the number of days between two dates.

Syntax:
Select DATEDIFF(day,startDate,endDate)


Example:
declare @startDate datetime
declare @endDate datetime

set @startDate = '2016-03-15'
set @endDate = '2016-03-16'

select DATEDIFF(dd, @startDate, @endDate) as DayDiffrence


 Demo:
Sql Server: Get number of days between two dates

What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.

Share this

Share on FacebookTweet on TwitterPlus on Google+


EmoticonEmoticon