title: ORA-00907: missing right parenthesis with decode and case in oracle sql
body: <p>I am putting fromdate and todate as parameter I want to get the previous month date of fromdate  and when todate not the date in same month of fromdate I need to put last date of the fromdate month but if todate is date in month of fromdate I need to put it as it is,  when user put for example from 1-1-2016 to 25-1-2016 I will get previous month 1-12-2015 to 25-12-2016 of the from month and I need to check the todate if it is in same month of fromdate  I will keep it but if it not for example from 1-1-2016 to 25-4-2016 I will make it 30-1-2016.
  I am trying to use decode and case but in both am getting same error 
  ORA-00907: missing right parenthesis</p>
  
  <p>my query In case </p>
  
  <pre><code> select (case ( when (LAST_DAY(TRUNC(TO_DATE(:fromdate ,'DD-MM-YYYY') , 'Month')) &lt;&gt; (TO_DATE(:fromdate ,'DD-MM-YYYY')))  
  then (DATE between ADd_MONTHS(TO_DATE(:fromdate ,'DD-MM-YYYY') , -1) and LAST_DAY(TRUNC(TO_DATE(:todate ,'DD-MM-YYYY') , 'Month')))
  else (DATE between ADD_MONTHS(TRUNC(TO_DATE(:fromdate ,'DD-MM-YYYY') , 'Month'),-1) and TO_DATE(:todate ,'DD-MM-YYYY'))
   end))
   FROM  dual;
  </code></pre>
  
  <p>my query in decode </p>
  
  <pre><code>select DECODE((TO_DATE(:fromdate ,'DD-MM-YYYY')) , LAST_DAY(TRUNC(TO_DATE(:fromdate ,'DD-MM-YYYY') , 'Month')) , 
  (DATE  between ADd_MONTHS(TO_DATE(:fromdate ,'DD-MM-YYYY') , -1) and ADd_MONTHS(TO_DATE(:todate ,'DD-MM-YYYY') , -1)) ,
  (DATE between ADD_MONTHS(TRUNC(TO_DATE(:fromdate ,'DD-MM-YYYY') , 'Month'),-1) and TO_DATE(:todate ,'DD-MM-YYYY'))
  FROM  dual ;
  </code></pre>