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.
I need to be able to add x number of months to a complete date (YYYYMMDD) in Dialog Manager but the only function I've found that does that is AYM but it only uses a date in Year-Month format...
But I'll have a problem if the current day doesn't exist in the new month ex: 20050331 + 6 months will give me 20050931 but September only have 30 days and my resulting date will be invalid.
I'm claculating that date to use it in the WHERE CLAUSE of an SQL statement on a MSSQL server via WebFocus. That's why it needs to be calculated in Dialog Manager.
Try the following... just truncate to the first of the month, add the months and then add the correct number of days. Like this... gives 20051002 for 20050331+6 months.
Thank you sooooo much. That's exactly what I was looking for. In fact, you must substract 1 day to the nb of days you are adding back to get exactly the desired date i.e. 20050331 + 6 months = 20051001.
Correction. Here is a better way. Essentially you just add the 6 months then test the date. If its not valid then remove one day and test it again. So 20050331 plus 6 months results in 20050930.
Do this three times (max number of times the date could be invalid ... FEB29 FEB30 FEB31.) Could put that in a loop but I didnt bother. Am I missing something people? Is there an easier way to do this?
-SET &DATE1='20050831'; -TYPE ORIGINAL DATE = &DATE1 -SET &DATETEMP=EDIT(&DATE1, '999999'); -SET &DATE2=AYM(&DATETEMP,6,'I6'); -SET &DAYOFMONTH=EDIT(&DATE1, '$$$$$$99'); -SET &DATENOW=&DATE2 | &DAYOFMONTH; -TYPE DATENOW = &DATENOW -*TEST TO SEE IF VALID -SET &TESTDATE = DATECVT(&DATENOW , 'I8YYMD' , 'YYMD'); -IF &TESTDATE NE 0 GOTO ALLDONE; -SET &DAYOFMONTH = &DAYOFMONTH -1; -SET &DATENOW=&DATE2 | &DAYOFMONTH; -TYPE DATENOW = &DATENOW -*TEST TO SEE IF VALID -SET &TESTDATE = DATECVT(&DATENOW , 'I8YYMD' , 'YYMD'); -IF &TESTDATE NE 0 GOTO ALLDONE; -SET &DAYOFMONTH = &DAYOFMONTH -1; -SET &DATENOW=&DATE2 | &DAYOFMONTH; -TYPE DATENOW = &DATENOW -*TEST TO SEE IF VALID -SET &TESTDATE = DATECVT(&DATENOW , 'I8YYMD' , 'YYMD'); -IF &TESTDATE NE 0 GOTO ALLDONE; -SET &DAYOFMONTH = &DAYOFMONTH -1; -SET &DATENOW=&DATE2 | &DAYOFMONTH; -TYPE DATENOW = &DATENOW -ALLDONE -TYPE FINAL DATE IS &DATENOW
-SET &END_DATE = DATECVT((DATEMOV(DATEADD((DATECVT(&START_DATE,'I8YYMD','YYMD')), 'M',&TIME_DURA),'EOM')),'YYMD','I8YYMD');This message has been edited. Last edited by: <Mabel>,
Posts: 406 | Location: Canada | Registered: May 31, 2004
Well, here's what they say in the help: Do not use DATEADD with Dialogue Manager. DATEADD requires a date to be in date format; Dialogue Manager interprets a date as alphanumeric or numeric.
It's working because you use DATEADD with DATECVT to convert the alphanumeric date into a real date. Good idea!
When using DATEADD, If the calculation using the month unit creates an invalid date, DATEADD corrects it to the last day of the month. And That's not what I want.
It's just because I'm converting an SAP/ABAP report into a Web Focus one and the function they used was calculating it like that. Since I want the new report to have the same results, I have no choice.
Try that code with the original date=20050830. You get a result of 20060302. Thats not what you want.
Correct me if Im wrong. You want to add 6 months. Then if the result is not a valid date (like FEB 30) then move the result to the first of the NEXT month. Right?
This will work under all circumstances:
-SET &DATE1='20050830'; -TYPE ORIGINAL DATE = &DATE1 -SET &DATETEMP=EDIT(&DATE1, '999999'); -SET &DATE2=AYM(&DATETEMP,6,'I6'); -SET &DAYOFMONTH=EDIT(&DATE1, '$$$$$$99'); -SET &DATENOW=&DATE2 | &DAYOFMONTH; -TYPE DATENOW = &DATENOW -SET &TESTDATE = DATECVT(&DATENOW , 'I8YYMD' , 'YYMD'); -IF &TESTDATE NE 0 GOTO ALLDONE; -*MOVE TO FIRST OF CURRENT MONTH -SET &DATETEMP=EDIT(&DATENOW, '999999')|'01'; -TYPE &DATETEMP -*ADD ONE MONTH -SET &DATENOW=DATECVT((DATEADD((DATECVT (&DATETEMP, 'I8YYMD', 'YYMD')),'M', 1)), 'YYMD','I8YYMD'); -ALLDONE -TYPE FINAL DATE IS &DATENOW -EXIT