Skip to Content
0
Former Member
Jan 25, 2011 at 10:07 PM

Requires a user to input a date (condition [%0])

22 Views

Hi,

I'm trying to write a query that requires a user to input a date (condition [%0]). The data brought back would show invoices with activity but I need to get only the invoices that are 60 days past due from the date the user inputs.

--SELECT T0.[DocNum]'Invoice No.',

--T0.[CardCode],

--T0.[CardName],

--T1.PYMNTGROUP,

--T0.[DocDate],

--T0.[DocDueDate],

--DATEDIFF(DAY,T0.DOCDUEDATE,GETDATE())'Past Due',

--T0.[DocTotal] 'Balance Due',

--MAX(T2.RECONTACT)'Last Activity',

--max(t2.details)'Activity Details'

--FROM OINV T0 LEFT JOIN OCTG T1 ON T0.GROUPNUM=T1.GROUPNUM LEFT JOIN OCLG T2 ON T0.CARDCODE=T2.CARDCODE

--WHERE T0.[Docstatus] ='o' and

--T0.docduedate<getdate() -60

--GROUP BY T0.[DocNum], T0.[CardCode], T0.[CardName],T1.PYMNTGROUP, T0.[DocDate], T0.[DocDueDate] ,

--DATEDIFF(DAY,T0.DOCDUEDATE,GETDATE()),T0.[DocTotal]