Query to use DateDiff in SQL Server

Last Reply 5 months ago By dharmendr

Posted 5 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

You are viewing reply posted by: dharmendr 5 months ago.
Posted 5 months ago

Hi rakibxl,

Refer below query.

SQL

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

Output

13