How to Calculate Total Number of days between two specific dates in SQL Server

How to Calculate Total Number of days between two specific dates in SQL Server

In this post, Learn how to calculate total number. of days between two specific dates in SQL Server. 

To get a total no. of days between two specific dates, you use the DATEDIFF function of SQL Server.

declare @startDate datetime
declare @endDate datetime

set @startDate = '2019-01-01'
set @endDate = '2020-01-01'

select DATEDIFF(d, @startDate, @endDate) As 'Total No. of Days'

Output

 

Total No. of Days
-----------------
366

(1 row(s) affected)

2020-03-03