Focal Point
Dynamically Changing Column Titles with Dates

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3781078192

July 17, 2008, 09:45 AM
Winnie
Dynamically Changing Column Titles with Dates
I developed a report in Web Focus, but I want to change the column titles to display different dates. I used Dialogue Manager to create a variable and this uses a dateadd function. When I subtract days from a given date, it's not giving me the correct date. Instead, it looks at the date as an integer when doing the dateadd function.

Example:
-SET &DAY23= DATEADD(&YYMD,'D',-6);
-SET &DAY22= DATEADD(&YYMD,'D',-13);
-SET &DAY21 = DATEADD(&YYMD,'D',-20);
-SET &DAY20 = DATEADD(&YYMD,'D',-27);
DEFINE FILE SQLOUT
day23t/YYMD='&DAY23';
day22t/YYMD=' &DAY22';
day21t/YYMD=' &DAY21';
day20t/YYMD=' &DAY20';

END
TABLE FILE SQLOUT
PRINT
day20 AS '&DAY20'

day21 AS '&DAY21'
day22 AS '&DAY22'
day23 AS '&DAY23'
.
.
.

The output looks like this:
20080681 20080686 20080703 20080710

It should look like this:
20080619 20080626 20080703 20080710

Any suggestions?

Winnie


Winnie

Webfocus 7.7.3
July 17, 2008, 09:53 AM
Francis Mariani
The DATEADD function requires an input string in Date format. You have to use the DATECVT to first convert to Date format, then use DATEADD, then use DATECVT to convert back to alphanumeric string.

-SET &CDATE2 = DATECVT((DATEADD((DATECVT(&TODAY, 'I8YYMD', 'YYMD')), D, -6)), 'YYMD', 'I8YYMD');


It's easier to use the "Legacy" Date function AYMD to add/subtract a number of days:

-SET &DT1 = AYMD(&YYMD,-6,'I8YYMD');



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
July 17, 2008, 10:06 AM
Winnie
Thanks, Francis! This answered my question. I tried using the AYMD function, but didn't have quotes in the third parameter...My next question is can we truncate the year in the column title after that...instead of showing 20080710, I'd like it to display as 0710?

Winnie


Winnie

Webfocus 7.7.3
July 17, 2008, 10:23 AM
Francis Mariani
The quickest method would be to use EDIT:

-SET &DT1 = AYMD(&YYMD,-6,'I8YYMD');
-SET DT1X = EDIT(&DT1,'$$$$9999');
-TYPE &DT1 &DT1X



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
July 17, 2008, 10:55 AM
Prarie
Winnie...welcome to the Forum. Please go in and update your signature with which version you are running. Thanks

** Update signature
1) Logon to Focal Point and go into your complete profile.
2) Scroll down the page until you see the “Signature” field.
3) Fill in the signature you want to use. Here is a sample to model:

Prod: WebFOCUS 5.2.3 on Win 2K/IIS 6/ISAPI Mode
Test: WebFOCUS 7.1 on Win 2K/IIS 6/Weblogic 8.1/Servlet Mode

4) Once all changes are made/added, scroll down to the bottom of the page and click on the Submit button.


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
Thanks! I'll try this...


Winnie

Webfocus 7.7.3
Francis, that EDIT function worked great. I didn't really have to use the TYPE function. Thanks so much for your help!


Winnie

Webfocus 7.7.3
Winnie,

Please follow the instructions in Prarie's post. It is very important and helpful to those of us who try to help you.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
Ginny,

I followed the instructions in Prarie's post. updated my signature and clicked on the Submit button...I'm not sure what you are referring to. Thanks.

Winnie


Winnie

Webfocus 7.7.3
It is there now! It wasn't in your previous posts.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google