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     Count # of Mondays for the last month

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Count # of Mondays for the last month
 Login/Join
 
Member
posted
I am trying to count the number of Mondays that were in the last month. I have figured out how to calculate the number of business days last month for a different calculation using DATEMOV and BOM and EOM. Below is my code.

DEFINE FILE HOLDDEFINES
TODAY/MDYY='&DATEMDYY';
BEG_CUR_MO/MDYY=DATEMOV(TODAY,'BOM');
END_CUR_MO/MDYY=DATEMOV(TODAY,'EOM');
BEG_PRIOR_MO/MDYY=DATEADD(BEG_CUR_MO,'M',-1);
END_PRIOR_MO/MDYY=DATEMOV(BEG_PRIOR_MO, 'EOM');
bus_days_last_month/I2=DATEDIF(BEG_PRIOR_MO, END_PRIOR_MO, 'BD');

I know there is a BOW for the DATEMOV funtion, and I am sure that I will need to use the DATEADD or DATEDIFF funtion. I just don't know how to use them together logically.

Thanks in advance for your help!

Morgan
 
Posts: 21 | Location: NC, USA | Registered: June 12, 2006Report This Post
Master
posted Hide Post
Does this have to be in a Table? You could use a Maintain procedure. This routine gets today's date and the first day of this month. It then gets the first the day of last month. It them performs a loop, checks if the day is a Monday and updates the count.

MAINTAIN
MODULE IMPORT (MNTUWS);
COMPUTE NOW/MDYY=TODAY2();
COMPUTE NOW1/MDYY=DATEMOV(NOW, 'BOM', NOW1);
COMPUTE VAL/M=1;
COMPUTE LASTMONTH/MDYY = NOW1 - VAL;
COMPUTE LASTMONTH1/MDYY = DATEMOV(LASTMONTH, 'BOM', LASTMONTH1);
COMPUTE MCOUNT/I2=0;
REPEAT WHILE LASTMONTH1 LT NOW1
COMPUTE DAYS/WT= LASTMONTH1;
IF DAYS = 'MON' THEN COMPUTE MCOUNT=MCOUNT+1
COMPUTE LASTMONTH1 = LASTMONTH1 + 1;
ENDREPEAT
TYPE "MCOUNT = mcount" -* there should be a bracket in front of the mcount field
END

I am typing the count to the screen, but you could update a database.

Mark
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Member
posted Hide Post
I have never used a MAINTAIN before. After the loop ends, can I call it in a COMPUTE that is in a Table File?

Thank you,
Morgan
 
Posts: 21 | Location: NC, USA | Registered: June 12, 2006Report This Post
Master
posted Hide Post
You COULD EXEC a Table procedure and pass the value to it. It gets retreived as an &var. After the ENDREPEAT you would have:
EXEC procedure FROM MCOUNT -* here MCOUNT is the number of Mondays.

In the TABLE you would have &1. It can be in a heading, Where clause or any calculation. The variable passed to the table is received sequentially. If you had more than one variable in the FROM statement, you would receive &1 then &2.

Another thing you could do it use an INCLUDE or UPDATE statement after the loop to update a database. You could then get the value from that database in the Table.

Mark
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Expert
posted Hide Post
Morgan,

Extend your thought on the number of business days.

Create a new business day file where only Mondays are business days and then use it in your calculation to count business days. You'll end up with a count of Mondays.

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
Platinum Member
posted Hide Post
Use the DOWK function and just count the mondays. Instructions pasted below.
Good Luck

DOWK and DOWKL: Finding the Day of the Week
Available Operating Systems: All
Available Languages: reporting, Maintain
The DOWK and DOWKL functions find the day of the week that corresponds to a date.
The DOWK function returns the day as a 3-letter abbreviation; the DOWKL function
displays the full name of the day.
Syntax How to Find the Day of the Week
DOWK( indate, outfield)
or
DOWKL( indate, outfield)
where:
indate
Numeric
Is the input date in year-month-day format. If the date is not valid, the function
returns spaces. If the date specifies a 2-digit year and DEFCENT and YRTHRESH
values have not been set, the function assumes the 20th century.
outfield
DOWK: A4
DOWKL: A12
Is the name of the field to which the day of the week is returned, or the format of the
output value enclosed in single quotation marks.
Note: In Dialogue Manager, the format must be specified. In Maintain, the name of
the field must be specified.
Example Finding the Day of the Week
In this example, DOWK uses the argument in HIRE_DATE to determine the day of the
week employees were hired, and stores the result in DATED.
TABLE FILE EMPLOYEE
PRINT EMP_ID AND HIRE_DATE AND COMPUTE
DATED/A4 = DOWK(HIRE_DATE, DATED);
WHERE DEPARTMENT EQ 'PRODUCTION';
END
The output is:
EMP_ID HIRE_DATE DATED
------ --------- -----
071382660 80/06/02 MON
119265415 82/01/04 MON
119329144 82/08/01 SUN
123764317 82/01/04 MON
126724188 82/07/01 THU
451123478 82/02/02 TUE


FOCUS 7.6 MVS PDF,HTML,EXCEL
 
Posts: 115 | Location: Chicago, IL | Registered: May 28, 2004Report 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     Count # of Mondays for the last month

Copyright © 1996-2020 Information Builders