Query to use DateDiff in SQL Server

Last Reply 8 months ago By dharmendr

Posted 8 months ago

I have a vb.net datediff code look below

BlobSmartWorkingContract.MonthDuration = DateDiff(DateInterval.Month, New Date(BlobSmartWorkingContract.ContractStartDate.Value.Year, BlobSmartWorkingContract.ContractStartDate.Value.Month, 1), New Date(BlobSmartWorkingContract.ContractEndDate.Value.Year, BlobSmartWorkingContract.ContractEndDate.Value.Month, 1).AddMonths(1))

i want to do as it is in sql server anybody can help me please

Posted 8 months ago

Hi rakibxl,

Refer below query.


SELECT DATEDIFF(MONTH,'2017/10/1',DATEADD(MONTH,1,'2018/10/1'))