Skip to Content
0
Former Member
Mar 26, 2009 at 07:11 AM

Help in query

32 Views

Dear All,

I am using a query as under :

SELECT T0.[DocNum], T4.[Territory], T5.[descript],T0.[DocDate], T0.[DocDueDate], DateDiff(d,T0.Docdate, T0.DocDueDate) As 'Days Diff', DateDiff(d,T0.DocDueDate, getdate()) as 'OverDue Days',T0.[Series], T1.[SeriesName], T0.[Project], T2.[SlpName], T0.[CardCode], T0.[CardName], T0.[GroupNum], T3.[PymntGroup], T0.[DocTotal], T0.[DiscSum], T0.[PaidSum], T0.[DpmAmnt], T0.[U_FinRemarks], T0.[U_SalesRemarks] FROM OINV T0  INNER JOIN NNM1 T1 ON T0.Series = T1.Series INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode INNER JOIN OCTG T3 ON T0.GroupNum = T3.GroupNum INNER JOIN OCRD T4 ON T0.CardCode = T4.CardCode INNER JOIN OTER T5 ON T4.Territory = T5.territryID WHERE T0.[DocDate] between '[%0]' and '[%1]' and T1.[SeriesName] = [%2] and T0.DocStatus = 'O'

Its working fine. Now I want an addtional column which gives me the overdue no of days when I am running a report from the DocDate parameter of From and To 01/01/08 to 29/02/2009. I want to get the Overdues No of days calculated based on the second parameter of DocDate e.g 29/02/2009. Means I want to see till 29/02/2009 how much overdue its there ( means no of days )

But the above query is giving me the OverdueDays till the current date in which I am running the report. Means if I run the report on today e.g 26/03/2009, its giving me till today the overdue days but I want it to get overdue days in the Document Date parameter which I have selected.

Please guide.

Regards,

Kamlesh