In this article, you will learn how to calculate total no. of days between two specific dates in SQL Server.
To get a total no. of days between two specific dates, we use the DATEDIFF
function of SQL Server.
Here is the query to calculate the total no. of days between two specific dates:
declare @startDate datetime
declare @endDate datetime
set @startDate = '2020-01-01'
set @endDate = '2021-01-01'
select DATEDIFF(d, @startDate, @endDate) As 'Total No. of Days'
Total No. of Days
-----------------
366
(1 row(s) affected)
I hope this article will help you to understand how to calculate total no. of days between two specific dates in SQL Server.
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!
Comments