Reputation: 21
select DATEDIFF(m,0,GETDATE()) as date
when I execute the query I got answer as 1407 but I am unable to get in which format the answer is in, can anyone explian
Upvotes: 0
Views: 469
Reputation: 1530
Your output 1407. so from 1900 to 2017 we have totally 1407 months.because you using the parameter as m
Upvotes: -1
Reputation: 239654
DATEDIFF
takes three parameters - the datepart
that describes what units you want the result to be in and two dates.
In your case, you're passing a value of 0
as the second argument, which gets implicitly converted to the datetime
1900-01-01T00:00:00.000
.
There are currently 1407 months between 1st January 1900 and today.
Upvotes: 4
Reputation: 132
You set the format with first param, in your case months
possible values are listed here: https://www.w3schools.com/sql/func_datediff.asp
And as shown in the example on w3, you can also use the name of the format, i.e. select DATEDIFF(month,0,GETDATE()) as date
Upvotes: -1