I would use the following, this allows the user to select it via a date selector.
1trunc(REAL_FINISHED) between NVL(&ABSENCE_PERIOD.DATE_FROM,TRUNC(sysdate)) and nvl(NVL(&ABSENCE_PERIOD.DATE_TO,&ABSENCE_PERIOD.DATE_FROM),trunc(sysdate))
I would use the following, this allows the user to select it via a date selector.
1trunc(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.)
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.)
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.
1SELECT*
2FROM some_view
3WHERE real_finished != TRUNC(real_finished);
4
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?
Page 1 / 1
I think its the “/” characters in your parameter name causing the issue. Try removing that.
I would use the following, this allows the user to select it via a date selector.
1trunc(REAL_FINISHED) between NVL(&ABSENCE_PERIOD.DATE_FROM,TRUNC(sysdate)) and nvl(NVL(&ABSENCE_PERIOD.DATE_TO,&ABSENCE_PERIOD.DATE_FROM),trunc(sysdate))
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.
Jurwrote:
I would use the following, this allows the user to select it via a date selector.
1trunc(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.)
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.)
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.
1SELECT*FROM some_view WHERE real_finished != TRUNC(real_finished);
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.