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.
The DATEADD subroutine is for smart dates and Dialogue Manager dates, by definition, are legacy dates. Therefore, you should use legacy date subroutines to reformat.
You can play with this to tweak to your own requirements.
Or you can use DATECVT to reformat the dates. Use the search button above and search the forum for the DATECVT subroutine. There are lots and lots of posts on this.
I'm all too familiar with the conversions, just not clear on why they're necessary here when the same function seems to work fine in the first case but not the second.
WebFOCUS Version 7.1.1, Build 118, Apache Tomcat/5.0.19 JAVA version 1.4.2_13
DATEADD requires an "offset" (or "smart") date value in arg 1.
To operate on &YYMD, which contains the date in calendar form, use DATECVT to transform it into the equivalent offset value, apply DATEADD to that, and apply DATECVT again to regain calendar-date format.
Here it is step-by-step, and combined as a one-liner:
Why did subtracting 1 day to get the end-date seem to work? My guess is, either the "D" code is forgiving where the 'M' code is not; or more likely 20080819 (the value in &YYMD) was interpreted as an offset and nature took its course: subtracting one day gives an offset date of one less, which looks like the calendar date you want. But that will not work crossing a month boundary (try it with &YYMD=20080901)
- Jack Gross WF through 8.1.05
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
I guess I'll have to stick with DATECVT. It would nice to understand why it works the first time without a conversion but not the second, but I guess that's a matter of the processing under the hood.
WebFOCUS Version 7.1.1, Build 118, Apache Tomcat/5.0.19 JAVA version 1.4.2_13
Why did subtracting 1 day to get the end-date seem to work? My guess is, either the "D" code is forgiving where the 'M' code is not; or more likely 20080819 (the value in &YYMD) was interpreted as an offset and nature took its course: subtracting one day gives an offset date of one less, which looks like the calendar date you want. But that will not work crossing a month boundary (try it with &YYMD=20080901)
Ah, that makes sense. I was trying to get around using a conversion but I guess that's not an option.
WebFOCUS Version 7.1.1, Build 118, Apache Tomcat/5.0.19 JAVA version 1.4.2_13
See my post above. I guess we crossed in the mail.
Why would the DATEADD call, with &YYMD as first argument, work for adding Days but overflow for Months?
To compute DATEADD(smart_date, 'M', months) the DATEADD function has to determine the calendar components of smart_date, in order to figure out the adjusted date, and then convert that back to offset form. That fails when the input smart_date valus is out of reasonable range (&YYMD = offset of +20080819 = calendar date 568800530 = May 30 of year 56,880!). The function is not set up to reconvert such a far-off date back to offset form, and the output is a garbage value (which overflows when displayed as an 8-digit integer).
On the other hand, DATEADD(smart_date, 'D', days) can always be computed by blindly adding the increment, since both the smart_date value and the increment value share the same granularity. So DATEADD merrily adds -1 to 20,080,819 and gives you 20,080,818, which looks like yesterday's date. -- But test your code with -SET &YYMD=20080901; and see what happens.
- Jack Gross WF through 8.1.05
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005