Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]Get Last Business Day
Go
New
Search
Notify
Tools
Reply
  
[SOLVED]Get Last Business Day
 Login/Join
 
Master
posted
Hi,

I would like to get the last business day by using DATEADD but it seems like not working.

Here is my code

SET HDAY=TEST
SET BUSDAYS = _MTWTF_

-SET &PREVDAY=DATEADD(&YYMD,'BD'-1);

-TYPE PREVDAY &PREVDAY
-EXIT

The above code returns 0. I tried 'WD' but even this is not working correct when I try to get previous dates.

Am I missing anything here.

Thanks,

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


WFConsultant

WF 8105M on Win7/Tomcat
 
Posts: 780 | Location: Florida | Registered: January 09, 2005Reply With QuoteReport This Post
Virtuoso
posted Hide Post
From the functions manual:
quote:
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.

To use DATEADD in Dialogue Manager, you will need to use the DATECVT function to convert your DM date to a valid SmartDate value, then perform your DATEADD, and then convert the result back to a DM value.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Reply With QuoteReport This Post
Master
posted Hide Post
Thanks Dan.

That works.


WFConsultant

WF 8105M on Win7/Tomcat
 
Posts: 780 | Location: Florida | Registered: January 09, 2005Reply With QuoteReport This Post
Master
posted Hide Post
I forget who initially suggested this, may have been Francis, but this works great. Create DEFINE FUNCTIONs for DATEADD, DATEDIF and DATEMOV for use with Dialogue Manager. Just include the following in the edasprof and it is always available:

-*
-*  Use this function to use DATEADD in Dialogue Manager
-*
 DEFINE FUNCTION UDATEADD(INDATE/A8YYMD, INUNIT/A2, INNBR/I4)
   INDATE1/YYMD    = INDATE;
   UDATEADD1/YYMD  = DATEADD(INDATE1, INUNIT, INNBR);
   UDATEADD/A8YYMD = UDATEADD1;
 END
-RUN
-*
-*  Use this function to use DATEDIF in Dialogue Manager
-*
 DEFINE FUNCTION UDATEDIF(FROM_DATE/A8YYMD, TO_DATE/A8YYMD, DIF_UNIT/A2)
   FRDT/YYMD       = FROM_DATE;
   TODT/YYMD       = TO_DATE;
   UDATEDIF1/YYMD  = DATEDIF(FRDT, INDT, DIF_UNIT);
   UDATEDIF/A8YYMD = UDATEDIF1;
 END
-RUN
-*
-*  Use this function to use DATEMOV in Dialogue Manager
-*
 DEFINE FUNCTION UDATEMOV(INDATE/A8YYMD, INMVTO/A3)
   INDATE1/YYMD    = INDATE;
   UDATEMOV1/YYMD  = DATEMOV(INDATE1, INMVTO);
   UDATEMOV/A8YYMD = UDATEMOV1;
 END
-RUN


Now you can do this:

SET HDAY=TEST
SET BUSDAYS = _MTWTF_
-RUN
-SET &PREVDAY=UDATEADD(&YYMD,'BD',-1);
-SET &LASTDAY=UDATEMOV(&YYMD,'EOM');
-SET &BDAYSDIF=UDATEDIF(&PREVDAY,&LASTDAY,'BD');
-TYPE &YYMD &PREVDAY &LASTDAY &BDAYSDIF

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


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 905 | Location: Oklahoma City | Registered: October 27, 2006Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]Get Last Business Day

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.