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] DATEADD() not working correctly:

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] DATEADD() not working correctly:
 Login/Join
 
Virtuoso
posted
Hey all,

So, I've had a procedure I've been using for an external procedure/population request to populate a form drop-down control. It's been working fine up till recently when the request throws an error due to the DATEADD() function I've been using adding to the day component incorrectly. Today's date is 20150728 (&YYMD) and if I try and add 7 days to today's date I get 20150735 instead of 20150804 for &THISWEEK1. Am I doing something wrong? Is &YYMD not considered a valid full-component date? I try using &DATEYYMD and get something that doesn't even resemble a date --> 41854.

My code:
SET HOLDLIST = PRINTONLY

-SET &THISWEEK1 = DATEADD(&YYMD, 'D', 7);
-*-SET &THISWEEK = EDIT(&THISWEEK1,'9999/99/99');
-SET &YEAR = EDIT(&YYMD,'9999$$$$');

DEFINE FILE DIMDATE
WKEND_MDYY/MDYY = DATECVT(WEEKENDING, 'YYMD', 'MDYY');
END
TABLE FILE DIMDATE
BY HIGHEST WEEKENDING
BY WKEND_MDYY
WHERE WEEKENDING LE '&THISWEEK1';
WHERE FISCALYEAR GE '&YEAR';
ON TABLE PCHOLD FORMAT XML
END
-RUN


Output if I use &YYMD for today's date:
0 NUMBER OF RECORDS IN TABLE=        1  LINES=      1
 0 ERROR AT OR NEAR LINE     18  IN PROCEDURE ADHOCRQ FOCEXEC *
 (FOC177) INVALID DATE CONSTANT: 20150735
 (FOC009) INCOMPLETE REQUEST STATEMENT
 BYPASSING TO END OF COMMAND


Output if I use &DATEYYMD for today's date:
0 NUMBER OF RECORDS IN TABLE=        1  LINES=      1
 0 ERROR AT OR NEAR LINE     18  IN PROCEDURE ADHOCRQ FOCEXEC *
 (FOC177) INVALID DATE CONSTANT: 41854
 (FOC009) INCOMPLETE REQUEST STATEMENT
 BYPASSING TO END OF COMMAND


Any help would be greatly appreciated.

Thanks in advance!

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


8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.
 
Posts: 1113 | Location: USA | Registered: January 27, 2015Report This Post
Virtuoso
posted Hide Post
Look it up.

"DATEADD requires a date to be in date format. Since Dialogue Manager interprets a date as alphanumeric or numeric, and DATEADD requires a standard date stored as an offset from the base date, do not use DATEADD with Dialogue Manager unless you first convert the variable used as the input date to an offset from the base date. "
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
You cannot use the Date functions in Dialogue Manager without first converting the date string into a date value. Check this out:

-SET &DATEIN = '20150328';
-SET &DATEADD6 = DATECVT((DATEADD((DATECVT(&DATEIN, 'I8YYMD', 'YYMD')), 'D', 6)), 'YYMD', 'I8YYMD');
-TYPE IN: &DATEIN / OUT: &DATEADD6

The innermost DATECVT function call converts the string value &DATEIN to a smart date. Then the DATEADD function runs and then the outermost DATECVT function converts the smart date back to a string.


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
quote:


You cannot use the Date functions in Dialogue Manager without first converting the date string into a date value. Check this out:

-SET &DATEIN = '20150328';
-SET &DATEADD6 = DATECVT((DATEADD((DATECVT(&DATEIN, 'I8YYMD', 'YYMD')), 'D', 6)), 'YYMD', 'I8YYMD');
-TYPE IN: &DATEIN / OUT: &DATEADD6

The innermost DATECVT function call converts the string value &DATEIN to a smart date. Then the DATEADD function runs and then the outermost DATECVT function converts the smart date back to a string.

Francis



Superb answer. This is what keeps the forums so useful, more useful than the manuals or the help files as far as I'm concerned.



 
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007Report This Post
Master
posted Hide Post
make certain that the date fields you want to manipulate in the date functions are in the format the functions expect them to be in. That seems to be the issue.


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Expert
posted Hide Post
John, I haven't found any info on using Date functions in the manual. The forum is definitely more helpful. Now, is it "Dialogue Manager" or "Dialog Manager"? That will affect a forum search Smiler


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
Francis,

Thank you so much for explaining the issue so that I could actually understand what I had skipped a beat on, and then giving me an example of how it should be done! If only all responses were similar to yours. I really appreciate the help. If I could buy ya lunch, I would. lol I wasn't sure if &YYMD was indeed treated as a string or a date. The manual really doesn't make it too clear (at least for me). So, first you must convert it to a date, add whatever date component, then convert it back to a string for use. Gotchya.

Again, thank you for being patient and kind enough to help me learn the ropes. Somewhat new to all this WF and DM voodoo.

And Jack, I always try to glean from the manual before I come to the forums or open a case. A lot of the time either the manual is lacking, or I just don't understand what it is trying to get at. Thanks though for your input.

Thanks to all who tried to help!


8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.
 
Posts: 1113 | Location: USA | Registered: January 27, 2015Report This Post
Virtuoso
posted Hide Post
I have an old paper copy of the "(Almost) 1001 Ways to Work With Dates in WebFOCUS" book that was published about ten years back. Very useful, but it's strange looking in an index for something after years of typing words into search boxes.

It used to be $40, now it's $117. $97 in ebook form. http://www.aviter.com/keysheet/home/dates-book/

If you use dates a lot it may be worth dropping a C-note on this critter. Or just ask Francis.



 
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007Report This Post
Virtuoso
posted Hide Post
Old version is still available for $40 here -- http://documentation.informati...400251.1106&Price=40

That's a paper copy. 360 pages of dateness.



 
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007Report This Post
Virtuoso
posted Hide Post
Thanks for the links and info John!


8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.
 
Posts: 1113 | Location: USA | Registered: January 27, 2015Report 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] DATEADD() not working correctly:

Copyright © 1996-2020 Information Builders