Skip to Content
avatar image
Former Member

Filtrar Consulta por Fecha y Titular

Buenos Días, necesito filtar esta consulta por fecha y titular pero ha sido posible, he intentado asi: WHERE T0.[DocDate] BETWEEN [%0] AND [%1] AND T0.[Project] = [%2]

pero al ejecutar me da error, si alguien pudiera ayudarme le agradecería!!!!

****************************************************************************

SELECT T0.[Project], T0.[Canceled], T0.[DocDate] AS 'Fecha O.V.', T0.[DocNum] AS 'No. O.V.', T0.[CardName], T0.[DocTotal]+T0.[DiscSum]-T0.[VatSum] AS 'Valor O.V.',


(SELECT sum (T10.[Credit]) - sum (T10.[Debit]) FROM JDT1 T10 WHERE T10.[Project] = T0.[Project] AND  T10.[Account] in('41209501','41209502','41209598','41209599','4120960101','4120960102','4120960103','4120960104','4120960105','4120960201','4120960202','4120960203','4120960204','4120960299','4120960301','4120960302','4120960303','4120960304','4120960305','4120960306','4120960401','4120960402','4120960403','4120960404','4120960405','4120960406','41309501','41309502','4130960101','4130960102','4130960103','4130960104','4130960105','4130960106','4130960107','4130960108','4130960109','4130960110','4130960111','4130970102','413595','413596','4135970101','4135970103','4135970199','4135970201','4135970202','4135970203','4135970204','4135970205','4135970301','4135970302','4135970303','4135970304','4135970305','4135970306','4135970307','4135970308','413599','414595','415590','41559001','4155910101','4155910102','4155910201','4155910202','4155910301','4155910302','4155910401','4155910402','4155910403','4155910404','4155910405','41559501','41559502','41559503','41559504','41559505','41559506','41559507','41750101')) AS Ingresos,


(SELECT sum (T10.[Debit]) - sum (T10.[Credit]) FROM JDT1 T10 WHERE T10.[Project] = T0.[Project] AND  T10.[Account] in('510503','510506','510515','510518','510524','510527','510530','510533','510536','510539','510542','510545','510548','510551','510560','510563','510568','510569','510570','510572','510575','510578','510584','510590','510591','510595','511005','511010','511015','511020','511025','511030','511035','511095','511505','511510','511515','511520','511535','511540','511545','511570','511595','512005','512010','512015','512020','512025','512095','512505','512510','512515','513005','513010','513025','513030','513035','513040','513060','513095','513505','513510','513515','513520','513525','513530','513535','513540','513545','513550','51355001','51355002','513555','513560','51359501','51359502','51359503','51359504','51359505','514005','514010','514015','514020','514025','514095','514505','514510','514515','514520','514525','514540','515005','515010','515015','515095','515505','515510','515515','515520','515525','515595','516005','516010','516015','516020','516025','516030','516035','516505','516510','516515','516595','519505','519506','519510','519515','519520','519525','519530','519535','519540','519545','519550','519555','519560','519565','519570','519575','519580','519595','51959501','51959502','51959503','51959504','51959505','51959506','51959507','51959508','519905','519910','519915','519995','520503','520506','520507','520512','520515','520518','520521','520524','520527','520530','520533','520536','520539','520542','520545','520548','520551','520554','520557','520558','520559','520560','520561','520562','520563','520566','520568','520569','520570','520572','520575','520578','520581','520584','520590','520595','521005','521025','521035','521095','521505','521510','521540','522005','522010','522015','52205','522040','522095','522505','522510','523010','523035','523060','523070','523095','523505','523510','523515','523520','523525','523530','523535','523540','523545','523550','523555','523560','52359501','52359502','52359503','52359504','52359505','524005','524010','524015','524020','524025','524095','524505','524510','524515','524520','524525','524540','525005','525010','525015','525095','525505','525510','525515','525520','525525','52559501','52559595','526005','526010','526015','526020','526035','526515','526595','529505','529506','529510','529515','529520','529525','529530','529535','529540','529545','529550','529555','529560','529565','29570','529575','529595','52959506','52959507','529596','529910','710101','710102','710110','710115','720506','720515','720518','720524','720527','720530','720533','720536','720539','720545','720551','720560','720563','720568','720569','720570','720572','720575','720578','720584','720598','720599','72069','723505','725072','729505','730101','730506','730515','730518','730524','730527','730530','730533','730536','730539','730545','730551','730560','730563','730568','730569','730570','730572','730575','730578','730584','730585','731001','731025','731035','731040','731095','731505','731510','732010','732015','732025','733010','733035','733070','733095','73309501','733505','73350501','73350502','733510','733515','733520','733525','733530','733535','733540','733550','733551','733555','733560','733561','733580','733581','733582','73359502','73359503','73359504','73359505','73359595','734015','734510','734515','734516','735015','735095','735505','735510','735515','736005','736010','736015','736020','736035','739505','739506','739507','739508','739510','73952501','73952502','73953001','73953002','739535','739545','739560','739565','739570','739580','739595')) AS Costos,


(SELECT sum (T10.[Credit]) - sum (T10.[Debit]) FROM JDT1 T10 WHERE T10.[Project] = T0.[Project] AND  T10.[Account] in('510503','510506','510515','510518','510524','510527','510530','510533','510536','510539','510542','510545','510548','510551','510560','510563','510568','510569','510570','510572','510575','510578','510584','510590','510591','510595','511005','511010','511015','511020','511025','511030','511035','511095','511505','511510','511515','511520','511535','511540','511545','511570','511595','512005','512010','512015','512020','512025','512095','512505','512510','512515','513005','513010','513025','513030','513035','513040','513060','513095','513505','513510','513515','513520','513525','513530','513535','513540','513545','513550','51355001','51355002','513555','513560','51359501','51359502','51359503','51359504','51359505','514005','514010','514015','514020','514025','514095','514505','514510','514515','514520','514525','514540','515005','515010','515015','515095','515505','515510','515515','515520','515525','515595','516005','516010','516015','516020','516025','516030','516035','516505','516510','516515','516595','519505','519506','519510','519515','519520','519525','519530','519535','519540','519545','519550','519555','519560','519565','519570','519575','519580','519595','51959501','51959502','51959503','51959504','51959505','51959506','51959507','51959508','519905','519910','519915','519995','520503','520506','520507','520512','520515','520518','520521','520524','520527','520530','520533','520536','520539','520542','520545','520548','520551','520554','520557','520558','520559','520560','520561','520562','520563','520566','520568','520569','520570','520572','520575','520578','520581','520584','520590','520595','521005','521025','521035','521095','521505','521510','521540','522005','522010','522015','52205','522040','522095','522505','522510','523010','523035','523060','523070','523095','523505','523510','523515','523520','523525','523530','523535','523540','523545','523550','523555','523560','52359501','52359502','52359503','52359504','52359505','524005','524010','524015','524020','524025','524095','524505','524510','524515','524520','524525','524540','525005','525010','525015','525095','525505','525510','525515','525520','525525','52559501','52559595','526005','526010','526015','526020','526035','526515','526595','529505','529506','529510','529515','529520','529525','529530','529535','529540','529545','529550','529555','529560','529565','29570','529575','529595','52959506','52959507','529596','529910','710101','710102','710110','710115','720506','720515','720518','720524','720527','720530','720533','720536','720539','720545','720551','720560','720563','720568','720569','720570','720572','720575','720578','720584','720598','720599','72069','723505','725072','729505','730101','730506','730515','730518','730524','730527','730530','730533','730536','730539','730545','730551','730560','730563','730568','730569','730570','730572','730575','730578','730584','730585','731001','731025','731035','731040','731095','731505','731510','732010','732015','732025','733010','733035','733070','733095','73309501','733505','73350501','73350502','733510','733515','733520','733525','733530','733535','733540','733550','733551','733555','733560','733561','733580','733581','733582','73359502','73359503','73359504','73359505','73359595','734015','734510','734515','734516','735015','735095','735505','735510','735515','736005','736010','736015','736020','736035','739505','739506','739507','739508','739510','73952501','73952502','73953001','73953002','739535','739545','739560','739565','739570','739580','739595','41209501','41209502','41209598','41209599','4120960101','4120960102','4120960103','4120960104','4120960105','4120960201','4120960202','4120960203','4120960204','4120960299','4120960301','4120960302','4120960303','4120960304','4120960305','4120960306','4120960401','4120960402','4120960403','4120960404','4120960405','4120960406','41309501','41309502','4130960101','4130960102','4130960103','4130960104','4130960105','4130960106','4130960107','4130960108','4130960109','4130960110','4130960111','4130970102','413595','413596','4135970101','4135970103','4135970199','4135970201','4135970202','4135970203','4135970204','4135970205','4135970301','4135970302','4135970303','4135970304','4135970305','4135970306','4135970307','4135970308','413599','414595','415590','41559001','4155910101','4155910102','4155910201','4155910202','4155910301','4155910302','4155910401','4155910402','4155910403','4155910404','4155910405','41559501','41559502','41559503','41559504','41559505','41559506','41559507','41750101')) AS Resultado


FROM ORDR T0<br>
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 17, 2016 at 02:41 PM

    Hola Esteban, gusto saludarte.

    Prueba estableciendo los parámetros bajo la siguiente lógica.

    DECLARE @FechaInicial AS DATETIME 
    DECLARE @FechaFinal AS DATETIME
    
    SELECT @FechaInicial = T0.F_RefDate, @FechaFinal = T0.T_RefDate From OFPR T0 Where T0.F_RefDate = '[%0]' AND T0.T_RefDate = '[%1]' 
    SET @FechaInicial = CONVERT(DATETIME, '[%0]', 112) 
    SET @FechaFinal = CONVERT(DATETIME, '[%1]', 112) 
    
    SELECT T0.[Project], T0.[Canceled], T0.[DocDate] AS 'Fecha O.V.', T0.[DocNum] AS 'No. O.V.', T0.[CardName], T0.[DocTotal]+T0.[DiscSum]-T0.[VatSum] AS 'Valor O.V.',
    
    FROM ORDR T0 Where T0.DocDate Between @FechaInicial  AND @FechaFinal 
    

    Suerte.

    Add comment
    10|10000 characters needed characters exceeded