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     [CLOSED] Date question

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Date question
 Login/Join
 
Member
posted
Hello to All,

I need to calculate a date. I am unsure how to ask the question so I will try to explain:

Today is Tuesday Jan 04, 2011, one year ago it was Tuesday Jan 05, 2010 and two years ago it was Tuesday Jan 06, 2009.

The reason I need this function, if you want to call it that, is we run 2 and 3 year comparinson reports. I run the same report 3 times for the 3 different days. I would like to run this report once and be done with it. Does anyone have a function that would solve my problem? Also it would have to account for leap year.

If you have any questions please let me know.

Thanks
David

This message has been edited. Last edited by: Kerry,
 
Posts: 1 | Registered: December 04, 2006Report This Post
Expert
posted Hide Post
Today is Tuesday, January 4, 2011.

One year ago it was Monday, January 4, 2010.

etc.

This is a program that calculates the dates. It uses the DATEADD function. Since the program uses Dialogue Manager variables in the function, the variable is converted to a date field using the DATECVT function, then to be able to use the results of the DATEADD function, DATECVT is used once again to convert the result back to an integer. DATEADD most likely takes care of leap years.

-* File dates4.fex

-SET &INPUT_DATE = '20110104';

-*-- DETERMINE PRIOR DATES ---
-SET &INPUT_DATE1 = DATECVT( DATEADD(DATECVT(&INPUT_DATE,'I8YYMD','YYMD'),'Y', -1), 'YYMD','I8YYMD');
-SET &INPUT_DATE2 = DATECVT( DATEADD(DATECVT(&INPUT_DATE,'I8YYMD','YYMD'),'Y', -2), 'YYMD','I8YYMD');
-SET &INPUT_DATE3 = DATECVT( DATEADD(DATECVT(&INPUT_DATE,'I8YYMD','YYMD'),'Y', -3), 'YYMD','I8YYMD');

-*-- DISPLAY DATES ---
-TYPE Input date: &INPUT_DATE
-TYPE Input date 1 year ago: &INPUT_DATE1
-TYPE Input date 2 years ago: &INPUT_DATE2
-TYPE Input date 3 years ago: &INPUT_DATE3


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
Virtuoso
posted Hide Post
If you want to stay with the same day of week and week number, this may work for you. Change WEEKFIRST for your standard.
-SET &INPUT_DATE = '2011/01/04';
 
SET WEEKFIRST = ISO1 
-*SET WEEKFIRST = ISO2 
 
DEFINE FUNCTION MOVE_YR(date/A10,period/I4)
Act_Date/HYYMD  = HINPUT(10,date,8,'HYYMD');
Week/I4         = -(period * 52);
New_Date/HYYMD  = HADD(Act_Date,'wk',Week,8,'HYYMD');
Week_Date/HYYMD = HADD(New_Date,'wk',HPART(Act_Date,'wk','I2') - HPART(New_Date,'wk','I2'),8,'HYYMD');
MOVE_YR/A10     = HCNVRT(Week_Date,'(HYYMD)',10,'A10');
END
-RUN
 
-TYPE Input date initial value: &INPUT_DATE
-SET &N_YR1 = MOVE_YR(&INPUT_DATE,1);
-SET &N_YR2 = MOVE_YR(&INPUT_DATE,2);
-SET &N_YR3 = MOVE_YR(&INPUT_DATE,3);
-SET &N_YR4 = MOVE_YR(&INPUT_DATE,4);
-TYPE Input date: &INPUT_DATE changed to: &N_YR1
-TYPE Input date: &INPUT_DATE changed to: &N_YR2
-TYPE Input date: &INPUT_DATE changed to: &N_YR3
-TYPE Input date: &INPUT_DATE changed to: &N_YR4

6-Jan. Had to tidy up as this was not the best example of using date functions...

This message has been edited. Last edited by: Alan B,


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Expert
posted Hide Post
That's a nice use of DEFINE FUNCTION.




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 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     [CLOSED] Date question

Copyright © 1996-2020 Information Builders