How to make a query in the database 10 days ahead and 10 days behind the current date?

0

Today I can do the query 10 days ago as shown in the query below, I just can not deploy the 10 days ahead of the current date.

SELECT 
  'vw_saldobancario'.'contaApelido',
  'vw_saldobancario'.'tipoMovimento',
  'vw_saldobancario'.'historico',
  (
    vw_saldobancario.debitosPendentes + vw_saldobancario.debitos
  ) AS debitos,
  (
    vw_saldobancario.creditosPendentes + vw_saldobancario.creditos
  ) AS creditos,
  'vw_saldobancario'.'dataMovimento',
  'vw_saldobancario'.'conta_bancaria_id',
  IF (
    creditosPendentes > 0 
    OR debitosPendentes > 0,
    'SIM',
    'NAO'
  ) AS Pendentes 
FROM
  'vw_saldobancario' 
WHERE 'dataMovimento'  BETWEEN DATE_ADD(CURRENT_DATE(), INTERVAL -10 DAY) AND CURRENT_DATE()
  AND 'conta_bancaria_id' = 3 
GROUP BY 'idHistorico'
    
asked by anonymous 29.11.2018 / 15:09

1 answer

-1

If you plan to include current date plus 10 the function is DATE_ADD (date, INTERVAL value addunit). You do not need to include the sign: DATE_ADD (CURRENT_DATE (), INTERVAL 10 DAY)

    
29.11.2018 / 15:20