Hello,
How can I pull the data from a table twice for 2 different date ranges 2 times in a month ? I need to pull the data on 16th of the current month and another at the end of the current month.
For example: If the current month date is 16 then I need to pull the data from the table where the datefield in the table ranges between 1st through 15th of current month.
If the current month date is the end of the month like 30 or 31st or Feb 28th then I need to pull the data from the table where the datefield in the table ranges between 16th through end of the current month.
Something like this shown below. But the code seems to be not working.
Select Case when TO_CHAR(datefield, 'YYYY-DD') = TO_CHAR(sysdate, 'YYYY') || '-' || '16' then
datefield between TRUNC(sysdate, 'MONTH') and TRUNC(sysdate, 'MONTH') + 14
when TO_CHAR(datefield, 'YYYY-DD') = TO_CHAR(sysdate, 'YYYY') || '-' || '31' then
datefield between TRUNC(sysdate, 'MONTH') + 15 and last_day(sysdate)
end
from table
Thanks