Skip to main content
Solved

Quick Report - data between two parameter dates

  • August 11, 2020
  • 9 replies
  • 1363 views

Forum|alt.badge.img+8

Hi,

In Quick Report, I have to get data FromDate to ToDate using a DateTime column

I used this:

WHERE o.REAL_FINISHED BETWEEN TO_DATE('&From_dd/mm/yyyy','dd/mm/yyyy') AND TO_DATE('&To_dd/mm/yyyy','dd/mm/yyyy')

 

I’m getting when we go to view report 

 

It works fine 

When I export data I’m getting this error:  Excel Plugin Error: Undefined bind variable 'from_dd' in Excel file

Any idea how to sort this issue?

Best answer by Rusiru Dharmadasa

I think its the “/” characters in your parameter name causing the issue. Try removing that.

View original
Did this topic help you find an answer to your question?

9 replies

Rusiru Dharmadasa
Superhero (Employee)
Forum|alt.badge.img+19

I think its the “/” characters in your parameter name causing the issue. Try removing that.


Forum|alt.badge.img+8
  • Author
  • Sidekick
  • 27 replies
  • August 12, 2020

Hi @Rusiru 

It works now 

Is it possible to add comments by default when we press View Report?

I want to provide date format information.

Thanks,

Narsi.


  • Superhero (Employee)
  • 1426 replies
  • August 12, 2020
Narsi wrote:

Hi @Rusiru 

It works now 

Is it possible to add comments by default when we press View Report?

I want to provide date format information.

Thanks,

Narsi.

You add comments in the report definition, like below.

 


Rusiru Dharmadasa
Superhero (Employee)
Forum|alt.badge.img+19

Yes, there is a dedicated box for comments when you created the SQL quick report. Hope this is what you are expecting.

 

 


Forum|alt.badge.img+8
  • Author
  • Sidekick
  • 27 replies
  • August 12, 2020

Thank you so much @Rusiru and @anmise 


Forum|alt.badge.img+9
  • Hero (Customer)
  • 59 replies
  • August 12, 2020

I would use the following, this allows the user to select it via a date selector.

trunc(REAL_FINISHED) between NVL(&ABSENCE_PERIOD.DATE_FROM,TRUNC(sysdate)) and  nvl(NVL(&ABSENCE_PERIOD.DATE_TO,&ABSENCE_PERIOD.DATE_FROM),trunc(sysdate))

Forum|alt.badge.img+8
  • Author
  • Sidekick
  • 27 replies
  • August 12, 2020

Thanks @Jur 


Forum|alt.badge.img+8
  • Author
  • Sidekick
  • 27 replies
  • August 17, 2020

Hi @Jur @Rusiru @anmise 

Is it possible to default/pre-populate values on the date parameter fields when we press “View Report”?

I mean date paramer fields would be populated automatically when we press “View Report”

“Date From” would be the first day of last week and “Date To” would be today’s date.

For example:

Today’s Date: 17-08-2020

From Date: 10-08-2020

To Date: 17-08-2020

 

Thanks,

Narsi.


durette
Superhero (Customer)
Forum|alt.badge.img+19
  • Superhero (Customer)
  • 525 replies
  • August 27, 2020
Jur wrote:

I would use the following, this allows the user to select it via a date selector.

trunc(REAL_FINISHED) between NVL(&ABSENCE_PERIOD.DATE_FROM,TRUNC(sysdate)) and  nvl(NVL(&ABSENCE_PERIOD.DATE_TO,&ABSENCE_PERIOD.DATE_FROM),trunc(sysdate))

If you're going to nest NVL functions, it might be better to use COALESCE. (As a bonus, COALESCE is ANSI SQL and not Oracle-specific, so developers coming from other relational database systems may understand it.)

TRUNC(real_finished) BETWEEN COALESCE(&absence_period.date_from,
                                      TRUNC(SYSDATE))
                         AND COALESCE(&absence_period.date_to,
                                      &absence_period.date_from,
                                      TRUNC(SYSDATE))

 

By applying a function to the view or table column before it’s compared to the user value, it forces the system to run a full scan and compute that function on every record. The database isn’t smart enough to work backwards, predict what the outcome of that function should be, and find records that satisfy the output condition. This means this query won’t take advantage of indexes if you have any (notwithstanding function indexes which aren’t often used).

If you happen to have an index on REAL_FINISHED, this next iteration of the predicate will take advantage of it. (Pick the variant you find more readable.)

real_finished BETWEEN COALESCE(&absence_period.date_from,
                               TRUNC(SYSDATE))
                  AND COALESCE(&absence_period.date_to,
                               &absence_period.date_from,
                               TRUNC(SYSDATE)) + (1 - (1 / (60 * 60 * 24)))

real_finished BETWEEN COALESCE(&absence_period.date_from,
                               TRUNC(SYSDATE))
                  AND COALESCE(&absence_period.date_to,
                               &absence_period.date_from,
                               TRUNC(SYSDATE)) + (86399 / 86400)

If you know your REAL_FINISHED is always truncated back to midnight, then that would make your query even simpler. I’m not familiar with this view, but you could look in your data to discover that.

SELECT *
  FROM some_view
 WHERE real_finished != TRUNC(real_finished);

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