Monday, March 14, 2016

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

No comments:

Post a Comment