1
votes

Hi While trying to execute the below code iam getting the error.

error : SQL compilation error: Can not convert parameter 'EXTRACT(month from CURRENT_DATE())' of type [NUMBER(2,0)] into expected type [DATE]

Code : select current_date, case when day(CURRENT_DATE) between 1 and 10 then LAST_DAY(ADD_MONTHS(CURRENT_DATE(), - 2), 'MM') else MONTH(CURRENT_DATE) end as dates;

My intention is when days of date between 1 to 10 then it should return month -2. if it is above the dates then it should return previous month.

in this case. as it is november(1 to 10) then it should return month of september. that means 9. if it is greater then novemebr 10, then it should return october month.

1

1 Answers

0
votes

Every part of your CASE statement needs to return the same datatype. Your CASE statement should probably look something like this:

case when day(CURRENT_DATE) between 1 and 10 then MONTH(ADD_MONTHS(CURRENT_DATE(), - 2), 'MM') else MONTH(CURRENT_DATE) end as dates