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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
30 days ago
 Login/Join
 
Platinum Member
posted
I have:

-SET &TODAY2 = DATECVT(&MDYY,'MDYY','MDYY');

Which gives me today's date.

Now I'm trying to do:

-SET &BACK30DAYS = &TODAY2-30;

Which gives me 5061978 (30 yeara ago).

Does anyone know how to get the value for 30 days ago?


Production - 7.6.4
Sandbox - 7.6.4
 
Posts: 241 | Location: Bethesda, MD | Registered: August 14, 2007Report This Post
Virtuoso
posted Hide Post
Use the DATEADD function with a -30 for number of days to add. Don't have my functions book at the moment so I'm not sure of all the parms.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Virtuoso
posted Hide Post
CWM,
Try:
  
-SET &D30=AYMD(&YYMD, -30, 'I8YYMD');
-TYPE &YYMD &D30


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Expert
posted Hide Post
CWM,

To add an explanation that might be helpful, variables do NOT have an associated "format" so using DATECVT on the variable &MDYY gives you nothing more than your original &MDYY. Also the resultant value is not a "date" but a number - i.e. 5072008 instead of 05072008. You cannot act on it as you could a database field because there is no concept of a "date" format in a variable. So taking 30 "days" away is just performing a calculation of 5072008 - 30 giving you a numeric result of 5071978 and not a "date".

To get what you want, you will have to do as Darin and Danny suggest and action your date difference on the actual date variable, but remember, that will also give you a number and not a "date" albeit a numeric representation of a date. Also note that Danny used I8YYMD format in AYMD, that is because you cannot use MDYY formats in the AYMD function. If you use MDYY format in DATEADD (-SET &D30 = DATEADD(&MDYY, 'D', -30); ), then you will end up with exactly the same result as using your original method - i.e. 5071978 - a number that looks like a date but the wrong one. For me DATEADD is not the function to use with variables.

So, armed with the knowledge that "date" variables are actually a number and not a date, you therefore understand that 5072008 could be interpretted by the end user as 5th July 2008 or 7th May 2008 but internally it will always be 5 million, 72 thousand and 8!

Your way forward? I would use the AYMD format and adjust your code accordingly within any validation or predicate and remember that you are using a numeric representation of a date and not a real date. I would also recommend always using YYMD farmats for "date" variables.

T

This message has been edited. Last edited by: Tony A,



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Master
posted Hide Post
Actually, this has been covered in several other threads. To use the new date functions (DATEADD, DATEDIF, DATEMOV, etc.) with Dialogue Manager, you have to convert the &variable, ie. &YYMD, to a smart date, apply the desired function, then convert it back to an &variable format. In my case, I have a job that I need to run on the 3rd business day of the month and it has to respect our holiday file. Consider the following where I compute &RUNDT to be the 3rd business of the month.

-SET &RUNDT=DATECVT(DATEADD((DATEMOV(DATECVT(&YYMD,'I8YYMD','YYMD'),'BOM'),'BD',2),'YYMD','I8YYMD');

The innermost DATECVT take &YYMD and converts it to a smart date.
DATEMOV then "moves" the result to the 1st day of the month.
DATEADD then adds 2 business days to the 1st of the month.
The outermost DATECVT converts the smart date back to an I8YYMD format that DM can understand.

I can't take credit for this, someone first posted it, but it has been a life saver.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
Virtuoso
posted Hide Post
Don't let us forget to mention the well known book
"almost 1001 Ways to Work with Dates in WebFOCUS" buy it, it is worth the money!




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Platinum Member
posted Hide Post
So once you get the item into a smart date - which is number of days - you can do DAY kind of math ... - 30 days ... or even average 3 days. But since you do not think in number of days, use DATECVT to get it back to a YYMD domain.
-* add 30 days ...
-SET &RUNDT=DATECVT((DATECVT(&YYMD,'I8YYMD','YYMD')+30),'YYMD','I8YYMD');


Brian Suter
VP WebFOCUS Product Development
 
Posts: 200 | Location: NYC | Registered: January 02, 2007Report This Post
Guru
posted Hide Post
Unless you have an overriding reason for using DM, why not use a define such as this

ABCD/HMDYYs=HGETC(10, ABCD);
CERT_MINUS180/HMDYYs=HADD(ABCD, 'DAY-OF-YEAR', -30, 10, CERT_MINUS180);


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
 
Posts: 398 | Registered: February 04, 2008Report This Post
Expert
posted Hide Post
... and watch out for the bug in using date range selection with variables.

In 7.6..4, if you have
-SET &FRDATE = '01/05/2008';
-SET &TODATE = '01/06/2008';
.....
WHERE date_field FROM &FRDATE TO &TODATE
.....

You only get data with dates from 01/05/2008 through 31/05/2008.

Quick solution / workaround? Create temporary defined dates to hold &FRDATE and &TODATE and use them in the FROM ... TO

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Silver Member
posted Hide Post
CWM,
Try this,
-SET &30DAYSAGO = DATECVT((DATEADD((DATECVT(&YYMD,'I8YYMD','YYMD')),'D',-30)),'YYMD','I8YYMD');

which gives u 30 days back date with format ex: 20080408
If u want the Date in different format create virtuval field with formats available in WebFOCUS.

Ex: 30DBACK/YYMD = &30DAYSAGO;
which gives you date in format 2008/04/08.

Thanks,
Saikumar.


WebFOCUS 8103 Appstudio, Dev Studio MRE
Client Windows 7, Serveron Unix.
Excel, PDF, HTML,AHTML
 
Posts: 38 | Registered: January 24, 2008Report This Post
Guru
posted Hide Post
quote:
Unless you have an overriding reason for using DM, why not use a define such as this

ABCD/HMDYYs=HGETC(10, ABCD);
CERT_MINUS180/HMDYYs=HADD(ABCD, 'DAY-OF-YEAR', -30, 10, CERT_MINUS180);


DM variables get calculated once only. DEFINE fields get calculated once for every row of data that passes initial WHERE statements.

Unless you have an overriding reason for using DEFINEs use DM variables to limit overhead.


ttfn, kp


Access to most releases from R52x, on multiple platforms.
 
Posts: 346 | Location: Melbourne Australia | Registered: April 15, 2003Report This Post
Expert
posted Hide Post
I agree with kp.

Only use Define when it is data related, e.g. 30 days prior to DB field.

DM is the way to go.

If you are ever worried about reaching the DM variable limit (1000 approx) use
-SET &VAR =;

Note: No space between the = and ;.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders