Focal Point
DOWK function

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7151009331

October 06, 2005, 03:29 PM
<Vanessa>
DOWK function
Hi everyone,

I am very new to FOCUS and have very little experience with it. I need to do the following. Calculate an Expiry date which should equal to todays date + 1 day. If the Expiry date falls on a Saturday or Sunday then the Expiry date should be move to the following Monday. The expiry and Input date should be in the MDY format but I belive that for DOWK you have to use the YMD format
Here is my code:
COMPUTE
INP_DATE/MDYY = '&MDYY';
EXP_DATEA/YYMD = '&YYMD' + 1;
EXP_DATEX/MDYY = INP_DATE + 1;
EXP_DATEY/MDYY = INP_DATE + 2;
DAY/A4 = DOWK(EXP_DATEA,DAY); ADJ/A1 = DECODE DAY
(MON '1' TUE '1' WED '1' THU '1' FRI '1' SAT '2' SUN '1');
EXP_DATE/MDYY = IF ADJ EQ '2' THEN EXP_DATEY ELSE EXP_DATEX;

The Input Date is the system date. The problem is no matter on what day the expiry date falls I am always getting the expiry date as the input date + 1.

I would really appreciate if someone could tell me what I was doing wrong.

Thanks
October 06, 2005, 04:05 PM
N.Selph
Your DECODE doesn't have an ELSE, so you don't know if DAY is even being calculated right. I suspect it isn't. I don't think you can add integer dates the way you are doing it. &MDYY is an integer date, not a smart date.
October 06, 2005, 04:24 PM
Francis Mariani
Vanessa, add 1 to the current date and then use the DATEMOV function to move the new date to the next week day.

-SET &ECHO=ALL;
-* CHOOSE A DATE TO TEST WITH
-*-SET &DATE1 = &YYMD;
-SET &DATE1 = 20051007;
-*
TABLE FILE CAR
PRINT
CAR
COMPUTE INP_DATEA/A8YYMD = '&DATE1'; NOPRINT
COMPUTE INP_DATE1/YYMD = INP_DATEA; NOPRINT
COMPUTE EXP_DATE1/YYMD = DATEMOV(INP_DATE1 + 1,'WD+'); NOPRINT
COMPUTE INP_DATE/MDYY = INP_DATE1;
COMPUTE EXP_DATE/MDYY = EXP_DATE1;
WHERE RECORDLIMIT EQ 1
END
October 06, 2005, 04:30 PM
<Vanessa>
Thanks for the reply.

I did check if the DOWK funtion is working or not and you are right, it is not.

I put in a change to the code:
COMPUTE MYDAY/A3 = DOWK(EXP_DATEA,'A3');
COMPUTE ADJ/I1 = DECODE MYDAY
(' ' 5 'MON' 1 'TUE' 1 'WED' 1 'THU' 2 'FRI' 1 'SAT' 1 'SUN' 1);
COMPUTE EXP_DATE/MDYY = IF ADJ EQ 5 THEN EXP_DATEY ELSE EXP_DATEX;

Any ideas as to what I should change?

Thanks
October 06, 2005, 05:05 PM
<Vanessa>
Hi Francis,

Thanks very much for your suggestion. It works just great.

Really appreciate the help
October 06, 2005, 05:16 PM
jimster06
Vanessa-
You may also want to take a look at the 'business days' capability of WebFOCUS. Also check out the 'holiday' feature. Also look at WD (Weekday) in DATEADD.
You can search for these by using the 'Search the Technical Documentation Library' button in the upper right corner of this screen.
HTH
October 06, 2005, 06:34 PM
Francis Mariani
Vanesa,

Welcome to the forum.

Cheers,

Francis.