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     Create a date-time out of a defined date

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Create a date-time out of a defined date
 Login/Join
 
Member
posted
I have the following code in a define:
WORK_DATE_YYMD/YYMD = '&DATEYYMD';
LAST_SAT_YYMD/YYMD = DATEMOV(WORK_DATE_YYMD,'EOW') - 6;
WE/YYMD = LAST_SAT_YYMD;
BEG_WK/YYMD = WE - 8;
END_WK/YYMD = WE + 2;

I want the BEG_WK and END_WK to be date-time fields to use in a WHERE clause against a field on my file that is date-time HYYMDs format. Apparently, going the other way doesn't pass the variables thru SQl - making the HYYMDs file field a YYMD field in a define and comparing that to BEG_WK, END_WK.
 
Posts: 20 | Location: Syracuse NY | Registered: August 26, 2005Report This Post
Expert
posted Hide Post
You don't need to define fields to use the date functions.

This should do it:
-SET &ECHO=ALL;

-SET &DT1 = '&YYMD';
-SET &LAST_SAT_YYMD = 
- DATECVT(( DATEMOV((DATECVT(20061107,'I8YYMD','YYMD')),'EOW')) - 6, 'YYMD','I8YYMD');

-SET &BEG_WK = AYMD(&LAST_SAT_YYMD, -8, 'I8YYMD');
-SET &END_WK = AYMD(&LAST_SAT_YYMD, 2, 'I8YYMD');

-SET &SEL1 = EDIT(&BEG_WK,'9999-99-99') | ' 00:00:00.000';
-SET &SEL2 = EDIT(&END_WK,'9999-99-99') | ' 23:59:59.999';

-TYPE &SEL1 &SEL2


&SEL1 and &SEL2 are the values you can use in the SQL WHERE statement (you may need to remove the milliseconds or make them microseconds .9999 for your DBMS). Put the DM variables in quotes in the SQL statement:

WHERE DB_DATE BETWEEN '&SEL1' AND '&SEL2'


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
Member
posted Hide Post
Thanks. I added this coding and it worked great. I didn't know you could use EDIT on an I8 field - always thought it needed to be A8. I put a trace on the run in dev studio and the focus code passed the WHERE statement through within it's internal SQL translator - which it didn't do before. It had just ignored the WHERE since I was using 2 DEFINED date fields to compare. With this coding I use the original file TRAN_DATE of HYYMDs.

-SET &LAST_SAT_YYMD = DATECVT(( DATEMOV((DATECVT(&YYMD,'I8YYMD','YYMD')),'EOW')) - 6, 'YYMD','I8YYMD');
-SET &BEG_WK = AYMD(&LAST_SAT_YYMD, -8, 'I8YYMD');
-SET &END_WK = AYMD(&LAST_SAT_YYMD, 2, 'I8YYMD');

-SET &SEL1 = EDIT(&BEG_WK,'9999/99/99') | ' 00:00:00.000';
-SET &SEL2 = EDIT(&END_WK,'9999/99/99') | ' 23:59:59.999';

-TYPE &SEL1 &SEL2
then put this in my TABLE FILE coding..
WHERE TRAN_DATE GE DT(&SEL1) AND TRAN_DATE LE DT(&SEL2);
 
Posts: 20 | Location: Syracuse NY | Registered: August 26, 2005Report This Post
Expert
posted Hide Post
Glad it worked out.


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
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Create a date-time out of a defined date

Copyright © 1996-2020 Information Builders