Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]AND/OR date range filter in one WHERE clause and also in a Define

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED]AND/OR date range filter in one WHERE clause and also in a Define
 Login/Join
 
Guru
posted
I need to filter data based on two date ranges as follows. I need to know where to put the parenthesis.

  
WHERE OPENDATE GE STARTDATE AND OPENDATE LE ENDDATE OR
CLDDATE GE STARTDATE AND CLDDATE LE ENDDATE 


I also need to do the same thing in a define
DEFINE FILE
QTR/I1   = IF OPENDATE GE Q1_BEG AND OPENDATE LE Q1_END OR CLDDATE GE Q1_BEG AND CLDDATE LE Q1_END THEN 1 ELSE
           IF OPENDATE GE Q2_BEG AND OPENDATE LE Q2_END OR CLDDATE GE Q2_BEG AND CLDDATE LE Q2_END THEN 2 ELSE
           IF OPENDATE GE Q3_BEG AND OPENDATE LE Q3_END OR CLDDATE GE Q3_BEG AND CLDDATE LE Q3_END THEN 3 ELSE
           IF OPENDATE GE Q4_BEG AND OPENDATE LE Q4_END OR CLDDATE GE Q4_BEG AND CLDDATE LE Q4_END THEN 4 ELSE 0; 




Thanks.

This message has been edited. Last edited by: Michele Brooks,


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
 
Posts: 244 | Registered: August 27, 2012Report This Post
Expert
posted Hide Post
WHERE (OPENDATE GE STARTDATE AND OPENDATE LE ENDDATE) OR
      (CLDDATE GE STARTDATE AND CLDDATE LE ENDDATE)

QTR/I1 =
     IF (OPENDATE GE Q1_BEG AND OPENDATE LE Q1_END) OR (CLDDATE GE Q1_BEG AND CLDDATE LE Q1_END) THEN 1
ELSE IF (OPENDATE GE Q2_BEG AND OPENDATE LE Q2_END) OR (CLDDATE GE Q2_BEG AND CLDDATE LE Q2_END) THEN 2
ELSE IF (OPENDATE GE Q3_BEG AND OPENDATE LE Q3_END) OR (CLDDATE GE Q3_BEG AND CLDDATE LE Q3_END) THEN 3
ELSE IF (OPENDATE GE Q4_BEG AND OPENDATE LE Q4_END) OR (CLDDATE GE Q4_BEG AND CLDDATE LE Q4_END) THEN 4
ELSE 0; 


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Guru
posted Hide Post
Thanks again. I thought that's what I tried; perhaps not. I'll this.


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
 
Posts: 244 | Registered: August 27, 2012Report This Post
Master
posted Hide Post
In my experience as a programmer, AND logic usually is evaluated first, then OR logic. So I'm curious as to whether it would still work without parentheses.

That being said, it's much easier to read and understand with parentheses, as the example Francis gave demonstrates.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Expert
posted Hide Post
I would always suggest using parentheses, for readability and making sure that the order of evaluation is what you specify.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Guru
posted Hide Post
Thanks all. Francis' example worked.


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
 
Posts: 244 | Registered: August 27, 2012Report This Post
Master
posted Hide Post
It's closed, but I thought to add a comment:

I agree with Waz - always use brackets, but once in a while the ORs and ANDs get more complicated than my tiny brain can accommodate, specially when several variables have to be in place to get the correct result.

In that case I split up the logic and assign a numeric flag to each individual result. Checking the value of the sum of the flags allows me to produce the result desired.


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
 
Posts: 674 | Location: Guelph, Ontario, Canada ... In Focus since 1985 | Registered: September 28, 2010Report This Post
Master
posted Hide Post
George, I think what you are suggesting is setting flags in a DEFINE section and testing the database fields there. Then in the WHERE section test just those flags. That's a great idea.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Master
posted Hide Post
Correct!


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
 
Posts: 674 | Location: Guelph, Ontario, Canada ... In Focus since 1985 | Registered: September 28, 2010Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]AND/OR date range filter in one WHERE clause and also in a Define

Copyright © 1996-2020 Information Builders