0

I'm trying to get a row result from a table. I created a stored procedure IN SQL DEVELOPER where I can filter between 2 dates

i have the next DATE in my table

FECHACARGA - 17/NOV/2020

In the sp im trying to compare 2 strings that comes like this:

fechaIni IN VARCHAR2, fechaFin IN VARCHAR2,

I make this to get the row that matches.

SELECT COUNT(1)  
       INTO V_TOTAL
FROM Z_DOMI2_IB_SERVICE_STATUS
WHERE CLIENTE = clientId AND
      TIPOARCHIVO = tipoDeArchivo AND 
      ESTADO = estadoArchivo AND
     TO_CHAR(FECHACARGA, 'DD-MM-YYYY') BETWEEN TO_CHAR(TO_DATE(fechaIni, 'DD-MM-YYYY'), 'DD-MM-YYYY')
                                          AND  TO_CHAR(TO_DATE(fechaFin, 'DD-MM-YYYY'), 'DD-MM-YYYY');

This doesn't work, this gives me nothing just blank.

Thanks!

2
  • please edit the question, show the exact table DLL and the exact table data Commented Nov 18, 2020 at 19:43
  • 2
    You really should store your dates in proper date data type columns Commented Nov 18, 2020 at 19:43

1 Answer 1

1

Don't use TO_CHAR, just use the DATE values:

SELECT COUNT(1)  
INTO   V_TOTAL
FROM   Z_DOMI2_IB_SERVICE_STATUS
WHERE  CLIENTE = clientId
AND    TIPOARCHIVO = tipoDeArchivo
AND    ESTADO = estadoArchivo
AND    FECHACARGA BETWEEN TO_DATE(fechaIni, 'DD-MM-YYYY')
                      AND TO_DATE(fechaFin, 'DD-MM-YYYY');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.