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 ?
Comment
Watch Question

Lokesh B RDeveloper
Top Expert 2015

Commented:
Hi,

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

DATEDIFF ( datepart , startdate , enddate )

https://msdn.microsoft.com/en-IN/library/ms189794.aspx
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)