Skip to main content
Question

Quick Report SQL Date Question

  • February 26, 2020
  • 2 replies
  • 433 views

Forum|alt.badge.img+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

  • Superhero (Employee)
  • 1468 replies
  • February 27, 2020
DevBob wrote:

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

 


Forum|alt.badge.img+10
  • Author
  • Sidekick (Customer)
  • 119 replies
  • February 27, 2020

Thanks, Anmise; that worked!

 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings