Question

Quick Report SQL Date Question

  • 26 February 2020
  • 2 replies
  • 381 views

Userlevel 4
Badge +10
  • Sidekick (Customer)
  • 119 replies

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

 


2 replies

Userlevel 7

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

 

Userlevel 4
Badge +10

Thanks, Anmise; that worked!

 

 

Reply