How count Difference Between Two date Using DatedIff

  By Rizwan Saqib   Posted on March-27-2018   649

MS Sql Server

The DATEDIFF() function returns the difference between two date values, based on the interval specified.         

 

Queries & Examples

1.Diiference Between Years

SELECT DATEDIFF(year, '2011/08/25','2017/08/25') AS Years;

It give use Result  Of Difference of year

-----------------------------------------------------

2.Diiference Between Month

SELECT DATEDIFF(MONTH, '2011/08/25','2017/08/25') AS Months;

----------------------------------------------------

3.Diiference Between Weeks

SELECT DATEDIFF(WEEK, '2011/08/25','2017/08/25') AS Weeks;

----------------------------------------------------

4.Diiference Between Days

SELECT DATEDIFF(DAY, '2011/08/25','2017/08/25') AS Days;

----------------------------------------------------

5.Diiference Between Minutes

SELECT DATEDIFF(MINUTE, '2011/08/25','2017/08/25') AS Minutes;

The DATEDIFF() function returns the difference between two date values, based on the interval specified.         

 

Queries & Examples

1.Diiference Between Years

SELECT DATEDIFF(year, '2011/08/25','2017/08/25') AS Years;

It give use Result  Of Difference of year

-----------------------------------------------------

2.Diiference Between Month

SELECT DATEDIFF(MONTH, '2011/08/25','2017/08/25') AS Months;

----------------------------------------------------

3.Diiference Between Weeks

SELECT DATEDIFF(WEEK, '2011/08/25','2017/08/25') AS Weeks;

----------------------------------------------------

4.Diiference Between Days

SELECT DATEDIFF(DAY, '2011/08/25','2017/08/25') AS Days;

----------------------------------------------------

5.Diiference Between Minutes

SELECT DATEDIFF(MINUTE, '2011/08/25','2017/08/25') AS Minutes;

By  Rizwansaqib966    27-Mar-2018 Views  649



You may also read following recent Post