Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional date 1

Status
Not open for further replies.

teknikalbody

Programmer
Mar 2, 2003
35
GB
Hi,
Please can you help... I'm new to reports from a forms background...

I am amending a report which always had one date that it brought back to be displayed however now there is a potential for two dates depending on the parameter the user chooses from a drop down option.

For example, if the user picks PAR_1 then it is ok to display the existing date it brings from the table DATE_1 but if the user picks PAR_2 then the date displayed needs to be DATE_1 - 3 months.

TIA for any suggestions / tips / help.
 
Modify SQL to bring the second date along with the original one. Use
Code:
SELECT
....
DATE_1,
ADD_MONTHS(DATE_1, -3) DATE_2,
...
Then in the group having DATE_1 create formula column of type Date that you will display instead of DATE_1 in the report.
The formula shoud conditionally switch between DATE_1 and DATE_2 depending on the parameter value. Something like:
Code:
...
begin
if :p_parameter = 'PAR_1' then return :DATE_1;
else return :DATE_2;
end if;
end
 
nagornyi thanks, I can see where you are going with this however please if it is not too much trouble, can you expand a little more on... "Then in the group having DATE_1 create formula column of type Date that you will display instead of DATE_1 in the report".

Thanx
 
OK.
1. Go to the data model and locate the group where DATE_1 field is. By that time, the DATE_2 field should also be there.
2. Make sure there is a tool bar to the left. If not, go the menu View--> Tool Palette (check it).
3.In the tool bar, click on the tool 'Formula Column" and then click within the group having the dates. That will create a formula column within the group.
4. Double click on that new column. In the property palette that opens change the type to Date and then go to the PL/SQL property. That opens PL/SQL editor.
5. In the editor window create the formula as discussed before, click Compile button, and close the window.

Please be back with any further questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top