[CLOSED] Efficient handling of indexes with date/time fields
Many of our ERP based reports are based on transaction date ranges. We are struggling with the best way to handle these and the advice we have been given doesn't seem to pass the date range to the database engine. All our dates are traditional DB date-time stamps. Our users want to enter dates (in prompts) in MDYY format. I have included code for a sample query.
Report: TABLE FILE DLYSTKLV PRINT CONO PCLS35 PNUM DLYSTKL_Year DLYSTKL_Month DLYSTKL_Date WHERE CONO EQ 'MD'; WHERE PCLS35 EQ 'LS' OR 'PA' OR 'MS'; WHERE ( DLYSTKL_Date GE &Start_Date ) AND ( DLYSTKL_Date LE &End_Date ); ON TABLE SET PAGE-NUM OFF ON TABLE NOTOTAL ON TABLE PCHOLD FORMAT HTML ON TABLE SET WEBVIEWER ON ON TABLE SET WEBVIEWTARG OFF ON TABLE SET HTMLCSS ON ON TABLE SET STYLE * INCLUDE = endeflt, $ ENDSTYLE END
Generated SQL: SELECT T1."DTSL", T1."CONO", T1."PNUM", T2."PCLS35" FROM DataMart.dbo.DLYSTKLV T1, DataMart.dbo.INP35 T2 WHERE (T2."CONO35" = T1."CONO") AND (T2."PNUM35" = T1."PNUM") AND (T1."CONO" = 'MD') AND (T2."PCLS35" IN('LS', 'PA', 'MS')); RECORDS IN TABLE= 0 LINES= 0
Join: JOIN INNER DLYSTKLV.DLYSTKLV.CONO AND DLYSTKLV.DLYSTKLV.PNUM IN DLYSTKLV TO UNIQUE INP35.INP35.CONO35 AND INP35.INP35.PNUM35 IN INP35 TAG J3 AS J3 END
We are on version 7.7.01 using SQL Server 2005This message has been edited. Last edited by: Kerry,
October 01, 2010, 11:39 AM
Dan Thomas
Since my post has several views and no response, I'll ask a more specific question: If you define a field that is derived from an indexed date field and you use the defined date field in your report should the SQL statement then use the actual date field referenced?
October 01, 2010, 11:43 AM
Kofi
Dan,
Be using dialogue manager to create timestamp field from your user input and be testing that value on real columns and not defined. I see in FP that this being not good.
I have be seeing DT(&dateinput) also but not be trying it.
Kofi
Client Server 8.1.05: Apache; Tomcat;Windows Server 2012 Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
October 01, 2010, 11:51 AM
Francis Mariani
Why are you DEFINEing the Date fields, and are they DLYSTKL_Date, DLYSTKL_Date, etc?
You can filter on the Date-Time Fields with something like this:
WHERE AS_OF_TMS GE DT(&ENDDATE 00:00:00.000) AND AS_OF_TMS LE DT(&ENDDATE 23:59:59.999)
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
October 04, 2010, 11:44 AM
jgelona
Dan,
Can't speak for SQL Server, but in Oracle, I get around this a couple of ways.
First, instead of using a DEFINE, I put 2 fields in the .mas, something like this.
Then I will add 1 day to the &END_DATE and my where clause will look something like this:
WHERE ( DTSLDT GE '&Start_Date' ) AND ( DTSLDT LT '&End_Date' );
This will generate the proper test for a datetime stamp. Since time is not part of &Start_Date or &End_Date, Oracle will make the time midnight (00:00:00.00000).
In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.