Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Business Date

Status
Not open for further replies.

silck

MIS
Jul 1, 2002
13
US
Is there a way to calculate the business date for each month, without creating a month group band?

When I use this formula using a month band it works great:

//begin formula
datevar fd;
datevar ld;
numbervar loop;
local numbervar busday;
numbervar span;
firstday:=date(year({ENTER_DATE}),month({ENTER_DATE}),1);

if month(fd)=12 then ld:=date(year(fd)+1,1,1)-1
else ld:=date(year(fd),month(fd)+1,1)-1;

span:=ld-fd;
For loop:= 0 to span do(
if dayofweek(fd+loop)in [2 to 6] then busday:=busday+1 else busday:=busday);


if date(2002,01,01) in fd to ld then busday:=busday-1;

busday
//end formula

What is being done is, this report is being grouped by companies and in the company group banding, it needs to show the business day count in there, but it will only show the count for the current month and none of the previous months. Is there a way to do this?

Any help is very much appreciated!
 
I'm assuming you want to show something like this:

Businessdays
Code:
currentmonth    last month    2 months ago
     23            20             23

You only need to have the first day recalulated and then change the {ENTER_DATE}'s to the new value. Change the red digit below to the number of months back you want to go. You'll need a new formula for each month. Don't forget to change the names of your variables.


datevar sub1month:= date(dateadd("m",-1,{@date}));
datevar fd1;
datevar ld1;
numbervar loop1;
local numbervar wds1;
numbervar span1;



fd1:=date(year(sub1month),month(sub1month),1);

if month(fd1)=12 then ld1:=date(year(fd1)+1,1,1)-1
else ld1:=date(year(fd1),month(fd1)+1,1)-1;

span1:=ld1-fd1;
For loop1:= 0 to span1 do(
if dayofweek(fd1+loop1)in [2 to 6] then wds1:=wds1+1 else wds1:=wds1);



wds1 Mike

 
No, it is more like
JAN FEB MAR
Business days 20 21 20

The date is based on the date the report is being ran. Ex.- Joe runs the report for 6-30-2002. The report should only show the info that month and the previous months and nothing else.

Also, this report has a fixed beginning date of 1-1-2002 and a parameter where the user enters an ending date. If the report ending date is 6-21-2002, how would I get it to calulate the business days for that month from that date?

Sorry if this is confusing and all your help is appreciated!
 
You'll have to create a formula for each month. Here is January's;
//start\//January
datevar fdjan;
datevar ldjan;
numbervar loopjan;
local numbervar wdsjan;
numbervar spanjan;

fdjan:=date(2002,01,01);
if {?date range} in date(2002,01,01) to date(2002,01,31) then ldjan:={?date range}
else ldjan:=date(2002,01,31);



spanjan:=ldjan-fdjan;
For loopjan:= 0 to spanjan do(
if dayofweek(fdjan+loopjan)in [2 to 6] then wdsjan:=wdsjan+1 else wdsjan:=wdsjan);



wdsjan
//end\

For each month, you'll have to change the date fields I've "bolded"
For the suppression, starting in February, use:
{?date range} < date(2002,02,01)
Changing the month for each formula.




Mike

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top