I have to do a aging of the stock that we have.
I am getting some problems in getting the items to fall into the correct aging buckets.
the code below is what I am using
INSERT INTO SAATempMth3 (Aging_Date,iflrd,NumberofMonths,item,ijavgcost)
SELECT aging_date,iflrd,datediff (month,iflrd, getdate())as NumberofMonths,ijitem,ijavgcost
WHERE datediff (month,iflrd, getdate()) > '2'
and datediff (month,iflrd, getdate()) <= '3'
now this code works ok, but what I am being told is that I should use a date difference, but how do I use datedifference and a get them to fall into the month buckets ???
e.g. the code that I am using works fine is iflrd=20090425 and getdate =20090630
but the code is wrong if I have iflrd=20090525 and getdate=20090630
Any help please !!!!