;

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


Tutorialsrack 24/02/2020 SQL SQL Server

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:

Query - To Calculate The Total Number 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'
Output

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!


Related Posts



Comments

Recent Posts
Tags