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     [Solved]Calculating previous year date for an MDYY date.

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[Solved]Calculating previous year date for an MDYY date.
 Login/Join
 
Platinum Member
posted
Hi All,

I am trying to calculate previous year date for below dates in MDYY format.

 
-DEFAULT &START_DATE   = '04/02/2018' ;
-DEFAULT &END_DATE     = '04/05/2018' ; 


DATECVT won't work directly on these dates as it is in MDYY ,so tried to convert to YYMD.
No ready to use functions are available as far as i undersatnd. So i spitted the MDYY and then joined back in YYMD format as below.

  
-SET &DATE_M = EDIT(&START_DATE,'99');
-SET &DATE_D = EDIT(&START_DATE,'$$$99');
-SET &DATE_YY = EDIT(&START_DATE,'$$$$$$9999');
-SET &START_DATE_YYMD = &DATE_YY||&DATE_M||&DATE_D;


My belief is that &START_DATE_YYMD is of A8YYMD format now.

SO tried to apply DATECVT on that to convert to YYMD.But it is not working.
Eventually i have to calculate previous year for the dates.To use DATEADD function i need to convert the dates to YYMD.
Am i doing something wrong? Code below.


  
-SET &ECHO='ALL';

-DEFAULT &START_DATE   = '04/02/2018' ;
-DEFAULT &END_DATE     = '04/05/2018' ;

-DEFAULT &PRIOR_START_DATE   = '01/02/2017' ;
-DEFAULT &PRIOR_END_DATE     = '02/01/2017' ;

-SET &DATE_M = EDIT(&START_DATE,'99');
-SET &DATE_D = EDIT(&START_DATE,'$$$99');
-SET &DATE_YY = EDIT(&START_DATE,'$$$$$$9999');
-SET &START_DATE_YYMD = &DATE_YY||&DATE_M||&DATE_D;

-SET &PRIOR_START_DATE = DATECVT(&START_DATE_YYMD,'A8YYMD','YYMD');
-*-SET &PRIOR_START_DATE = DATEADD(&START_DATE_YYMD,'Y',-1);
TYPE &DATE_M
TYPE &DATE_D
TYPE &DATE_YY
TYPE &START_DATE_YYMD
TYPE &START_DATE_MDYY
TYPE &PRIOR_START_DATE



Any suggestions ?

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


WF8206,Windows 7,8,10
HTM,PDF,EXCEL
 
Posts: 229 | Location: MI | Registered: September 13, 2017Report This Post
Virtuoso
posted Hide Post
srajeevan

Try this.

-SET &PYEAR_DATE=AYMD(&YYMD,-365,'I8YYMD');
-SET &START_DATE= EDIT(&PYEAR_DATE,'$$$$99') | '/' | EDIT(&PYEAR_DATE,'$$$$$$99') | '/' | EDIT(&PYEAR_DATE,'9999');


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
 
Posts: 2127 | Location: Customer Support | Registered: April 12, 2005Report This Post
Platinum Member
posted Hide Post
Hi,

Thanks for the reply.
You are calculating previous year from a YYMD date,but for my requirement,the date is in MDYY format.

If the date is YYMD format i can directly use DATECVT function or the AYMD function you provided.
Date being in MDYY is creating trouble for me as converting MDYY to YYMD is not happening properly when i split the date to components.


WF8206,Windows 7,8,10
HTM,PDF,EXCEL
 
Posts: 229 | Location: MI | Registered: September 13, 2017Report This Post
Expert
posted Hide Post
  
-DEFAULT &SELECT_DATE = '04/02/2018';
-SET &SELECTED_CURR_YR = EDIT(&SELECT_DATE,'$$$$$$9999');
-SET &SELECTED_PREV_YR = &SELECTED_CURR_YR - 1;
-SET &PREVIOUS_DATE = EDIT(&SELECT_DATE,'999999') || &SELECTED_PREV_YR;
-TYPE &SELECTED_CURR_YR
-TYPE &SELECTED_PREV_YR
-TYPE &PREVIOUS_DATE
-EXIT


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Platinum Member
posted Hide Post
Thanks Tom,

That was an easy fix.
I was thinking too much,i guess.


WF8206,Windows 7,8,10
HTM,PDF,EXCEL
 
Posts: 229 | Location: MI | Registered: September 13, 2017Report 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     [Solved]Calculating previous year date for an MDYY date.

Copyright © 1996-2020 Information Builders