var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Date difference in months
Hi to all,
I want to make an sql query that will subtract two dates and the difference will be number in months.
i have this table TestTable with Fields ACost, Adate, AMonth
my formula is this X = (Now-Adate), should give me number in months
and Y = (ACost/AMonth)
i want to get the product of X and Y, (X*Y).
how can i make this in sql views?
can anyone help me with this?
thanks a lot!
create view testview as
select ((datediff(m,Adate, getdate())) * (ACost/Amonth)) as val from testTable
you're genius man!
Just beware that DateDiff() actually counts boundaries, not units. So for example there is a month between 2006-02-28 and 2006-03-02, which occaisionally surprises folks.