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!
best regards,
saldiboyhow about
create view testview as
select ((datediff(m,Adate, getdate())) * (ACost/Amonth)) as val from testTable|||you're genius man!
thanks!|||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.
-PatP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment