I would like to pull all Open Sales Orders that do not have purchase orders and are more than 180 days old.
I tried the following query but does not seems to work exactly:
,DateAdd(Day,180,t0.DocDate) as Due180Days
, t2.lastName from ordr t0
inner join OCTG t1 on t0.GroupNum = t1.GroupNum
inner join OHEM t2 on t0.OwnerCode = t2.empID
where (t1.PymntGroup like '%prepaid%'
or t1.PymntGroup like '%deposit%')
and t0.DocStatus ='O'and t0.PoPrss='N' and DATEADD(Day,180,t0.DocDate)>180
Any hlep would be appreciated.