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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] REPEAT
 Login/Join
 
Silver Member
posted
The user enters a Date Range. I want to build a new table with all dates in this date range as my column. For example,
From Date : 03/20/2010 To Date : 04/31/2010
My Table should look like:
New Date
03/21/2010
03/22/2010
03/23/2010
….
04/31/2010.

This is my code:
-DEFAULT &FROMDT ='FOC_NONE'
-DEFAULT &TODT ='FOC_NONE'

-***TEST
-SET &FROMDT ='03/20/2010';
-SET &TODT ='04/31/2010';
-*****

FROMDATE/MDYY='&FROMDT';
TODATE/MDYY='&TODT';

NOOFDAYS=DATEDIF(FROMDATE,TODATE,'D');

-SET &NEWDATE = FROMDATE;
-REPEAT DATE_LOOP WHILE &NEWDATE LE NOOFDAYS;
-TYPE &NEWDATE
-SET &NEWDATE = &NEWDATE + 1;
-DATE_LOOP TYPE END: &NEWDATE

When I Run this I get an error msg :
“0 ERROR AT OR NEAR LINE 14 IN PROCEDURE BuildinDate.fexFOC
(FOC281) ALPHA ARGUMENTS IN PLACE WHERE NUMERIC ARE CALLED FOR”
I am a still new to webFocus and I need real help. Please could you help me with the right code. Also what is the command I should use to write it into a table. Appreciate all the help.

This message has been edited. Last edited by: Kerry,


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 29 | Registered: February 21, 2011Report This Post
Virtuoso
posted Hide Post
add a line at the start of your code that says

-SET &ECHO=ALL;

that will show more when you run

this couses the problem....it is not the correct code...
-SET &NEWDATE = &NEWDATE + 1;

search in this forum to find the correct formula
should be something like DATEADD




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Expert
posted Hide Post
Focus 101....

Dialog manager variables basically have one format, text. they can also be numeric, but that about it.

As you have dates, and want to add days to them the + 1 will just fail because you are adding 1 to a text string (The slashes make it one).

Follow Franks suggestion, you code is almost there.


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
Member
posted Hide Post
Here is what I did to twist and do calculation on the date.
  
-***TEST
-SET &FROMDT ='02/20/2000';
-SET &TODT ='03/20/2000';
-*****
-SET &FROMDATE = STRIP(10, &FROMDT, '/', 'A8');
-SET &FROMDATE = DATECVT(&FROMDATE, 'I8MDYY', 'YMD');
-SET &TODATE = STRIP(10, &TODT, '/', 'A8');
-SET &TODATE = DATECVT(&TODATE, 'I8MDYY', 'YMD');
-TYPE (&FROMDATE)  (&TODATE)

-SET &NOOFDAYS=DATEDIF(&FROMDATE,&TODATE,'D');
-TYPE &NOOFDAYS

-SET &NEWDATE = &FROMDATE;
-*REPEAT DATE_LOOP WHILE &NEWDATE LE &TODATE;
-REPEAT DATE_LOOP &NOOFDAYS TIMES;
-TYPE &NEWDATE
-*SET &NEWDATE = &NEWDATE + 1;
-SET &NEWDATE = DATEADD(&NEWDATE, 'D', 1);
-SET &NEWDT = EDIT(DATECVT(&NEWDATE, 'YMD', 'I8MDYY'),'99/99/9999');
-TYPE &NEWDT
-DATE_LOOP 
-SET &NEWDT = EDIT(DATECVT(&NEWDATE, 'YMD', 'I8MDYY'),'99/99/9999');
-TYPE END: &NEWDATE (&NEWDT)


WebFOCUS 764, Oracle to produce report
 
Posts: 23 | Location: CA | Registered: April 07, 2011Report This Post
Master
posted Hide Post
+1 TCL. This is actually exactly the problem I was trying to solve and ran across this post as you wrote it. I love the internet.

- ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
<JG>
posted
quote:

FROMDATE/MDYY='&FROMDT';
TODATE/MDYY='&TODT';

NOOFDAYS=DATEDIF(FROMDATE,TODATE,'D');

-SET &NEWDATE = FROMDATE;
-REPEAT DATE_LOOP WHILE &NEWDATE LE NOOFDAYS;


The reason for your error is that you are missing -SET & for FROMDATE , TODATE and NOOFDAYS

and & for the second NOOFDAYS
 
Report This Post
Virtuoso
posted Hide Post
Once you have this, only part of the question is solved
You have tot WRITE the data to a file, put it in a database or use it in an other way.

Would tis be a once only report, or is everyboday able to run this any time of the day?

How many tables with date sequence files will you have after some time




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Silver Member
posted Hide Post
Thank you everybody...It worked.

I put the data on to a file and it works just fine.


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 29 | Registered: February 21, 2011Report This Post
Master
posted Hide Post
quote:
Originally posted by TCL:
Here is what I did to twist and do calculation on the date.
  
-***TEST
-SET &FROMDT ='02/20/2000';
-SET &TODT ='03/20/2000';
-*****
-SET &FROMDATE = STRIP(10, &FROMDT, '/', 'A8');
-SET &FROMDATE = DATECVT(&FROMDATE, 'I8MDYY', 'YMD');
-SET &TODATE = STRIP(10, &TODT, '/', 'A8');
-SET &TODATE = DATECVT(&TODATE, 'I8MDYY', 'YMD');
-TYPE (&FROMDATE)  (&TODATE)

-SET &NOOFDAYS=DATEDIF(&FROMDATE,&TODATE,'D');
-TYPE &NOOFDAYS

-SET &NEWDATE = &FROMDATE;
-*REPEAT DATE_LOOP WHILE &NEWDATE LE &TODATE;
-REPEAT DATE_LOOP &NOOFDAYS TIMES;
-TYPE &NEWDATE
-*SET &NEWDATE = &NEWDATE + 1;
-SET &NEWDATE = DATEADD(&NEWDATE, 'D', 1);
-SET &NEWDT = EDIT(DATECVT(&NEWDATE, 'YMD', 'I8MDYY'),'99/99/9999');
-TYPE &NEWDT
-DATE_LOOP 
-SET &NEWDT = EDIT(DATECVT(&NEWDATE, 'YMD', 'I8MDYY'),'99/99/9999');
-TYPE END: &NEWDATE (&NEWDT)


Is it possible to increment the date in Dialog Manager as well?
-SET &NEXTDATE = HADD(&MYDATE, 'DAY', 1, 8, 'HYYMDS');

- ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Member
posted Hide Post
In fact, you can increase the date simply using

-SET &NEWDATE = &NEWDATE + 1;

in the original code.


WebFOCUS 764, Oracle to produce report
 
Posts: 23 | Location: CA | Registered: April 07, 2011Report This Post
Master
posted Hide Post
quote:
Originally posted by TCL:
In fact, you can increase the date simply using

-SET &NEWDATE = &NEWDATE + 1;

in the original code.


Sorry TCL, that gives me dates like 4/32 and 2/30. The HADD function would increment to the next realistic date. Your code works well until a user wants to span a month.

-ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Member
posted Hide Post
The code works perfectly well and gives all realistic dates with my environment. I ran the code below:

  
-***TEST
-SET &FROMDT ='02/27/2000';
-SET &TODT ='03/02/2000';
-*****
-SET &FROMDATE = STRIP(10, &FROMDT, '/', 'A8');
-SET &FROMDATE = DATECVT(&FROMDATE, 'I8MDYY', 'YMD');
-SET &TODATE = STRIP(10, &TODT, '/', 'A8');
-SET &TODATE = DATECVT(&TODATE, 'I8MDYY', 'YMD');
-TYPE (&FROMDATE)  (&TODATE)
-SET &NEWDATE = &FROMDATE - 1;
-REPEAT DATE_LOOP WHILE &NEWDATE LT &TODATE;
-SET &NEWDATE = &NEWDATE + 1;
-SET &NEWDT = EDIT(DATECVT(&NEWDATE, 'YMD', 'I8MDYY'),'99/99/9999');
-TYPE &NEWDT
-DATE_LOOP
-TYPE END: &NEWDATE (&NEWDT)


And produced the outcome as following:

-***TEST
-SET &FROMDT ='02/27/2000';
-SET &TODT ='03/02/2000';
-*****
-SET &FROMDATE = STRIP(10, 02/27/2000, '/', 'A8');
-SET &FROMDATE = DATECVT(02272000, 'I8MDYY', 'YMD');
-SET &TODATE = STRIP(10, 03/02/2000, '/', 'A8');
-SET &TODATE = DATECVT(03022000, 'I8MDYY', 'YMD');
-TYPE (36217) (36221)
(36217) (36221)
-SET &NEWDATE = 36217 - 1;
- &DATE_LOOP= 36216 LT 36221;
-SET &NEWDATE = 36216 + 1;
-SET &NEWDT = EDIT(DATECVT(36217, 'YMD', 'I8MDYY'),'99/99/9999');
-TYPE 02/27/2000
02/27/2000
- &DATE_LOOP= 36217 LT 36221;
-SET &NEWDATE = 36217 + 1;
-SET &NEWDT = EDIT(DATECVT(36218, 'YMD', 'I8MDYY'),'99/99/9999');
-TYPE 02/28/2000
02/28/2000
- &DATE_LOOP= 36218 LT 36221;
-SET &NEWDATE = 36218 + 1;
-SET &NEWDT = EDIT(DATECVT(36219, 'YMD', 'I8MDYY'),'99/99/9999');
-TYPE 02/29/2000
02/29/2000
- &DATE_LOOP= 36219 LT 36221;
-SET &NEWDATE = 36219 + 1;
-SET &NEWDT = EDIT(DATECVT(36220, 'YMD', 'I8MDYY'),'99/99/9999');
-TYPE 03/01/2000
03/01/2000
- &DATE_LOOP= 36220 LT 36221;
-SET &NEWDATE = 36220 + 1;
-SET &NEWDT = EDIT(DATECVT(36221, 'YMD', 'I8MDYY'),'99/99/9999');
-TYPE 03/02/2000
03/02/2000
- &DATE_LOOP= 36221 LT 36221;
-DATE_LOOP
-TYPE END: 36221 (03/02/2000)
END: 36221 (03/02/2000)


WebFOCUS 764, Oracle to produce report
 
Posts: 23 | Location: CA | Registered: April 07, 2011Report This Post
Master
posted Hide Post
If you guys read the documentation, you will find:

1. Every & variable in Dialogue Manager is alphanumeric;
2. Many of the date functions (DATEDIF, DATEADD, DATEMOV, etc.) do not work in Dialogue Manager and they only work with Smart Dates, which is just the number of days since 12/31/1900.

To get around #2, you have to use DATECVT function, for example:
-SET &YESTERDAY=DATECVT(DATEADD(DATECVT(&YYMD,'I8YYMD','YYMD'),'D',-1),'YYMD','I8YYMD');
-SET &MONTHEND=DATECVT(DATEMOV(DATECVT(&YYMD,'I8YYMD','YYMD'),'EOM'),'YYMD','I8YYMD');


The reason that what TCL is doing works is because when he does this:
-SET &FROMDATE = DATECVT(&FROMDATE, 'I8MDYY', 'YMD');

he is converting &FROMDATE to a smart date. That is why he can add 1 to it and it works. You cannot always add 1 to &YYMD and get a valid date.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
Master
posted Hide Post
quote:
Originally posted by TCL:
The code works perfectly well and gives all realistic dates with my environment. I ran the code below:


You're right. The first thing I did was to copy/paste out the pieces that appealed to me and started working on my own version, never really running the original code you provided in it's entirety (there I said it) Wink.

With some minor mods to fit my YYMD formats, this version works as expected.
-***TEST
-SET &FROMDT ='20110220';
-SET &TODT ='20110320';
-*****
-SET &FROMDATE = DATECVT(&FROMDT, 'I8YYMD', 'YYMD');
-SET &TODATE = DATECVT(&TODT, 'I8YYMD', 'YYMD');
-TYPE (&FROMDATE)  (&TODATE)

-SET &NOOFDAYS=DATEDIF(&FROMDATE,&TODATE,'D');
-TYPE &NOOFDAYS

-SET &NEWDATE = &FROMDATE;
-*REPEAT DATE_LOOP WHILE &NEWDATE LE &TODATE;
-REPEAT DATE_LOOP &NOOFDAYS TIMES;
-TYPE &NEWDATE
-*SET &NEWDATE = &NEWDATE + 1;
-SET &NEWDATE = DATEADD(&NEWDATE, 'D', 1);
-SET &NEWDT = EDIT(DATECVT(&NEWDATE, 'YYMD', 'I8YYMD'),'9999/99/99');
-TYPE &NEWDT
-DATE_LOOP 
-SET &NEWDT = EDIT(DATECVT(&NEWDATE, 'YYMD', 'I8YYMD'),'9999/99/99');
-TYPE END: &NEWDATE (&NEWDT)


Let that be a lesson to you kids out there. Before complaining some stolen code doesn't work right, first make sure you stole it all! Smiler Smiler Smiler

- ABT

P.S.
quote:
If you guys read the documentation

But there's just so much of it...


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Silver Member
posted Hide Post
[SOLVED]


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 29 | Registered: February 21, 2011Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders