Focal Point
Beginning of week (BOW) & End of Week (EOW) in DATEMOV ??

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

July 01, 2005, 08:00 PM
JPierce
Beginning of week (BOW) & End of Week (EOW) in DATEMOV ??
In the DATEMOV function, you can have it return a Beginning of week (BOW) value or End of week (EOW) value, which are Monday and Friday respectively.

ex. DATEMOV('2005/05/04','BOW') returns a BOW value of May 2nd for the date of May 4th.

Also, if an event happened on a Saturday WF will create the BOW date as the following Monday.

ex. DATEMOV('2005/05/07','BOW') returns a BOW value of May 9th for the event date of May 7th which is a Saturday.

However, I need that Saturday event to return a BOW value of May 2nd.

In other words, I need to force a week of Sunday - Saturday instead of the WebFOCUS default Saturday - Friday.

Thanks in advance for the help. I am just getting started in WF and have already found this forum to be valuable.
July 02, 2005, 05:17 PM
jimster06
Welcome to WF.
In regard to your query re setting business days, click on "Technical Documentation Library" at the top of this page and search for EOW. The system will return info on how to set up the week.
HTH
July 04, 2005, 04:35 PM
reFOCUSing
I ran into this problem sometime ago, I got around this was by using the function DOWK and moved the date back x number of days.
-SET &DT = '20050701';
-SET &FIRST_W_D = 
DOWK(&DT, 'A3');
-SET &FIRST_W_D = 
DECODE &
FIRST_W_D('SUN' '6' '
MON' '5' 'TUE' '4' 'WED' '3' '
THU' '2' 'FRI' '1' 'SAT' '0');
-SET &DT = AYMD(&DT, &
FIRST_W_D, 'I8');
-SET &END_YYMD = AYMD(&DT, -&TIME_BACK, 'I8');

This message has been edited. Last edited by: <Mabel>,
July 06, 2005, 02:01 PM
Lloyd
Have you tried :

SET WEEKFIRST = 1

never tried it with BOW or EOW but it should work fine.....
July 06, 2005, 06:36 PM
JPierce
I have tried all the suggestions provided. I am able to get the BOW and EOW variables to reflect the dates I am trying for (Sunday - Saturday).

However, the example of the 05/07/2005 (which is a saturday and should be the EOW) is still being returned with a BOW of 05/08/2005.

So this is not working quite yet. If anyone has more suggestions, I would appreciate it. I'm stuck.

Thanks for all your help so far.
July 06, 2005, 07:07 PM
Francis Mariani
Have you tried the business days setting:

SET BUSDAYS = smtwtfs

quote:
The following designates work days as Sunday, Tuesday, Wednesday, Friday, and Saturday:
SET BUSDAYS = S_TW_FS

July 06, 2005, 07:11 PM
JPierce
Yes, I have tried

SET BUSDAY = SMTWTFS

and SET BUSDAYS = SMTWTFS
(I've seen it listed both ways in different pieces of documentation) but to no avail.
July 06, 2005, 07:28 PM
Mickey
Hi,

I remember a similar problem and I tried something like this. Am not sure if theres a easier way, but this worked for me.

-SET &FRDT = '05072005' ;
-SET &FRDI = DAMDY(&FRDT,'I8');
-SET &FRBW = DATEMOV(&FRDI, 'BOW');
-SET &DIFF = &FRDI - &FRBW;
-SET &WKFI = IF &DIFF LT 0 THEN DATEMOV(&FRDI + &DIFF -1, 'BOW') ELSE IF &DIFF GT 0 THEN &FRDI - &DIFF ELSE &FRDI;
-SET &WKFR = DTYMD(&WKFI+1,'I8YYMD');
-TYPE &WKFR

M
July 06, 2005, 07:42 PM
Mickey
I added the + 1 to get a monday date. I realized that it wont work for a sunday. The original code was for a sunday to saturday week which is

-SET &WKFR = DTYMD(&WKFI ,'I8YYMD');

M
July 06, 2005, 07:44 PM
Francis Mariani
Here's another idea:

Use function DOWK to determine the day of the week for your date:

-SET &DOW = DOWK (&TODAY_DT,'A10');

If &DOW is 'SAT' or 'SUN' subtract 2 from your date (using a date function to do that) and then determine the BOW AND EOW!!!
July 06, 2005, 09:21 PM
JPierce
Finally got it. For anyone who might need this later, Here is what I ended up with and it works. FYI, BOW is always a Monday, and EOW is always a Friday.

Thanks to everyone who gave advice.

SET DEFCENT = 20

DEFINE FILE SO
STDT/MDYY = CLOSED_DT;
day_dowk/I6YMD = CLOSED_DT;
closed_dt_dow/A3=DOWK(day_dowk, 'A3');
STWK/MDYY = IF closed_dt_dow EQ 'SAT' THEN (STDT - 6) ELSE ( DATEMOV (STDT, 'BOW') -1 );
ENDWK/MDYY = IF closed_dt_dow EQ 'SAT' THEN STDT ELSE ( DATEMOV (STDT, 'EOW') + 1 );