Skip to main content

In my quick report I'd like to select a date range going back to the first of last year, so for today, 2/26/2020 it would select 1/1/2019 - today.

date_entered between sub_months(trunc(sysdate, 'YEAR'), 12) and trunc(sysdate, 'YEAR')-1/24/60/60

 

I tried a sub_month but that didn’t work. I’m already using this format for going forward one year:

OP_START_DATE between trunc(sysdate, 'YEAR') and add_months(trunc(sysdate, 'YEAR'), 12)-1/24/60/60

 

In my quick report I'd like to select a date range going back to the first of last year, so for today, 2/26/2020 it would select 1/1/2019 - today.

 date_entered between sub_months(trunc(sysdate, 'YEAR'), 12) and trunc(sysdate, 'YEAR')-1/24/60/60

 

I tried a sub_month but that didn’t work. I’m already using this format for going forward one year:

 OP_START_DATE between trunc(sysdate, 'YEAR') and add_months(trunc(sysdate, 'YEAR'), 12)-1/24/60/60

 

Maybe this could work?

SELECT date_entered
FROM your_table
WHERE reported_date BETWEEN ADD_MONTHS(TRUNC (SYSDATE,'YEAR'), -12) AND SYSDATE
ORDER BY date_entered ASC

 


Thanks, Anmise; that worked!

 

 


Reply