Calculate the number of days into months and days between two dates in SQL Server

Many times we use to calculate the experience of a person on that this code will you .
In this article we will calculate the number of day and month between two dates in SQL server .

 SqlQuery:-

declare @start date ='01/08/2013'
declare @end date ='03/10/2015'

select [MONTH and DAY]=(cast(DATEDIFF(MM,@start,@end) as varchar)+' Month(s) '
+ cast(DATEDIFF(DD, @start, DATEADD(MM, - DATEDIFF(MM, @start, @end),
            @end)) AS varchar) + ' Day(s) ')
 


Out-Put:-





Calculate the number of days into months and days between two dates in SQL Server Calculate the number of days into months and days between two dates in SQL Server Reviewed by NEERAJ SRIVASTAVA on 6:36:00 PM Rating: 5

No comments:

Powered by Blogger.