Showing results for 
Search instead for 
Did you mean: 

Date range problem in query

Former Member
0 Kudos

I need to pull a report of invoices within a date range that have specific tax codes in the rows. Here is what I have.

SELECT T0.[DocNum],T0.[DocDate], T1.[ItemCode], T1.[LineTotal], T1.[GrssProfit], T1.[TaxCode], T2.[CardName], T3.[SlpName], T0.[TrnspCode] FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OSLP T3 ON T0.SlpCode = T3.SlpCode

WHERE T0.[DocDate]  >= [%0] AND  T0.[DocDate]  <= [%1]

AND T2.[GroupCode] = 3

AND  T1.[TaxCode] = '93510'

OR  T1.[TaxCode] = '91301'

It seems to work fine if I have only one tax code however when I add the, OR  T1.[TaxCode] = '91301', it no longer respects the date range. Any help would be appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Active Contributor
0 Kudos

Or this:

AND  (T1.[TaxCode] = '93510'

OR  T1.[TaxCode] = '91301')

Answers (1)

Answers (1)

Active Contributor
0 Kudos


I would try to do this:

where taxcode in ('93510', '91301') and another conditions.

Kind regards

Agustín Marcos Cividanes