Sql Server: Get number of days between two dates | ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF 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

Post a Comment

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget