Convert days into month buckets

Last Post 21 Jul 2009 02:18 PM by SwePeso. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
JASBRYDEN
New Member
New Member

--
21 Jul 2009 11:38 AM
Hi

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
FROM Temp_Stock_Aging
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 !!!!
SwePeso
New Member
New Member

--
21 Jul 2009 02:18 PM
You want to search for a value which is GREATER than 2, and also LESS THAN OR EQUAL to 3?
Well, the sad truth is that the only value satisfying the filter is 3.
You are not authorized to post a reply.

Acceptable Use Policy