We help IT Professionals succeed at work.

SQL Query

Please explain why the following query = 1382

Select Datediff(Month, 0, Getdate())

Aren't I looking for the difference between todays date and 0 ?
Watch Question

Lokesh B RDeveloper
Top Expert 2015


You are looking for the difference between 0 and today date.

DATEDIFF ( datepart , startdate , enddate )

The dates start at 01/01/1900 and so 1382 is how many months ago this date is
ie 0 is 01/01/1900
select CONVERT(datetime, 0)