Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     SQL Server date/time fields
Go
New
Search
Notify
Tools
Reply
  
SQL Server date/time fields
 Login/Join
 
Master
posted
I would like to add a where clause to my report similar to
sqlserverDate_Field GE TIME_RIGHT_NOW - 24 hours

My usual method is to use &YYMD - 1, and this works for our AS400 as the dates are stored as numbers anyhow.

I'm sure this is easy for you fellas. Thank you for your patience.


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
 
Posts: 611 | Registered: January 04, 2007Reply With QuoteReport This Post
Master
posted Hide Post
It is basically the same logic as you are doing:
-SET &CMPDT=AYMD(&YYMD,-1,'I8YYMD');
-SET &CMPDTTM=EDIT('&CMPDT.EVAL','9999/99/99')|' '| &TOD;

I haven't tested this, you may have to adjust the syntax.


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
 
Posts: 755 | Location: TX | Registered: September 25, 2007Reply With QuoteReport This Post
Expert
posted Hide Post
This is what I do to manipulate date-time values for SQL selection criteria:

-SET &CUR_DTTM = &DATEYYMD | ' 00:00:00';

-SET &NEW_DTTM = HCNVRT(HADD(HINPUT(14, '&CUR_DTTM.EVAL' , 14, 'HYYMDS'), 'HOUR', -24, 8, 'HYYMDS'), '(HYYMDS)', 20, 'A20');

-TYPE &CUR_DTTM &NEW_DTTM


To use the Date-Time functions in Dialogue Manager, you need to convert the string to a Date-Time field and then convert it back to a string after the function is processed.

It looks daunting, but if you look at each part of the DM line of code, it's easy:

HINPUT(inputlength, 'inputstring', length, outfield) - Converts an Alphanumeric String to a Date-Time Value
HADD(value, 'component', increment, length, outfield) - Increments a Date-Time Value
HCNVRT(value, '(fmt)', length, outfield) - Converts a Date-Time Value to Alphanumeric Format

...
WHERE DATE_TIME_COLUMN GE '&NEW_DTTM'
...


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, 2005Reply With QuoteReport This Post
Master
posted Hide Post
thanks!


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
 
Posts: 611 | Registered: January 04, 2007Reply With QuoteReport This Post
Master
posted Hide Post
Francis,
I'm using the -set's that you mentioned, but we're getting an error on this line..

WHERE DELIVERED GE '&NEW_DTTM';

(FOC36346) INCORRECT USE OF DATE-TIME FIELD OR CONSTANT

The field is defined as 'HYYMDI' in the master file, if that makes a difference.

When we do a set echo on, the following shows up in the browser...
WHERE DELIVERED GE '2008/05/27 00:00:00 ';

Is there something I'm missing?


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
 
Posts: 611 | Registered: January 04, 2007Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Try WHERE DELIVERED GE ('&NEW_DTTM');


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Reply With QuoteReport This Post
Master
posted Hide Post
Prarie,
Thank you for your quick response!

We're getting the same error.

The echo shows
WHERE DELIVERED GE ('2008/05/27 00:00:00 ');

It looks like a valid date to me. Wink


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
 
Posts: 611 | Registered: January 04, 2007Reply With QuoteReport This Post
Expert
posted Hide Post
You MAY need to append '.000' for milliseconds to the end of the date-time, eg. '2008/05/27 00:00:00.000'.


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, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
The WHERE statement:

WHERE DT1 GT DT('&NEW_DTTM1');

(Forget about the .000).

-SET &ECHO=ALL;
-SET &CUR_DTTM = &DATEYYMD | ' 00:00:00';

-SET &NEW_DTTM1 = HCNVRT(HADD(HINPUT(14, '&CUR_DTTM.EVAL' , 14, 'HYYMDS'), 'HOUR', -24, 8, 'HYYMDS'), '(HYYMDS)', 20, 'A20') ;
-SET &NEW_DTTM2 = HCNVRT(HADD(HINPUT(14, '&CUR_DTTM.EVAL' , 14, 'HYYMDS'), 'HOUR', -22, 8, 'HYYMDS'), '(HYYMDS)', 20, 'A20') ;
-SET &NEW_DTTM3 = HCNVRT(HADD(HINPUT(14, '&CUR_DTTM.EVAL' , 14, 'HYYMDS'), 'HOUR', -20, 8, 'HYYMDS'), '(HYYMDS)', 20, 'A20') ;

DEFINE FILE CAR
DT1/HYYMDIA = IF COUNTRY EQ 'ENGLAND' THEN DT(&NEW_DTTM1) ELSE IF COUNTRY EQ 'JAPAN' THEN DT(&NEW_DTTM2) ELSE DT(&NEW_DTTM3);
END

TABLE FILE CAR
PRINT
COUNTRY
DT1
WHERE DT1 GT DT('&NEW_DTTM1');
ON TABLE HOLD
END


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, 2005Reply With QuoteReport This Post
Master
posted Hide Post
Good work on the DT() Francis.
Thanks again!


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
 
Posts: 611 | Registered: January 04, 2007Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Thanks Francis...that's what I meant...forgot my DT.


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Believe it or not, this is actually a good example of where the report painter does a good job. If you run it through that, it should put the DT() in there for you. Also, for what it's worth, in my experience, the DT() function only works with static (amper) values -- NOT with columns/defines... I believe it will actually throw an error if you try anything else.

Glad you got it working though.



Production: 7.6.6 WF Server  <=>  7.6.6 WF Client  <=>  7.6.6 Dev Studio
Testing: <none>
Using MRE & BID.  Connected to MS SQL Server 2005
Output Types: HTML, Excel, PDF
 
Posts: 230 | Location: Wichita, KS | Registered: May 27, 2005Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     SQL Server date/time fields

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.