1. ## add_bus_days(month_start(date()),1) Ending Date Results?

What should be the results of this combination function add_bus_days(month_start(date()),1) Using the first day of each month for the year 2006?

Ending_Date = ADD_BUS_DAYS( Starting_Date as D, Add_Days as N [, Ignore_Holiday_Flag as C [, Holiday_Table as C ]] )

My Diagnostics shows incrementing the Add_Days by 1 for each of the 1-20 some work days in a month works except for when the first day of the month starts on a week-end then the Ending_Date is incorrect.

For the year 2006 I found the following; for Stating_Date being changed manually for the first day of the month (01/01/2006) or by changing the computer date for the first of each month using (month_start) both were the same results.

(The asterisks show the incorrect months with double asterisks showing also incorrect holliday calculation )

Starting_Date 01/01/2006 the result for Ending_Date = 01/02/2006
Starting_Date 02/01/2006 the result for Ending_Date = 02/02/2006*
Starting_Date 03/01/2006 the result for Ending_Date = 03/02/2006*
Starting_Date 04/01/2006 the result for Ending_Date = 04/03/2006
Starting_Date 05/01/2006 the result for Ending_Date = 05/02/2006*
Starting_Date 06/01/2006 the result for Ending_Date = 06/02/2006*
Starting_Date 07/01/2006 the result for Ending_Date = 07/03/2006
Starting_Date 08/01/2006 the result for Ending_Date = 08/02/2006*
Starting_Date 09/01/2006 the result for Ending_Date = 09/04/2006**
Starting_Date 10/01/2006 the result for Ending_Date = 10/02/2006
Starting_Date 11/01/2006 the result for Ending_Date = 11/02/2006*
Starting_Date 12/01/2006 the result for Ending_Date = 12/04/2006*

I maybe using this function with the wrong understanding?

Thanks for any suggestions or input.

2. ## Looks right to me

What are you expecting to see??

date = {05/17/2006}
Month_start = {05/01/2006} which is the first day of the month of Date()

This is all correct. If you explain what you need, we can help better.

Scott

3. Originally Posted by Scott Emerick
What are you expecting to see??

date = {05/17/2006}
Month_start = {05/01/2006} which is the first day of the month of Date()

This is all correct. If you explain what you need, we can help better.

Scott
Also you have to set up the holiday dates in the built-in holiday table or create your own and you have to set the ignore holiday flag to something other than null.

= {09/05/2006}

4. Using this function add_bus_day(month_start(date(),1) with system date set to 01/01/2006 the result is 01/02/2006 which is the first business day of the month January 2006.

Using this function add_bus_day(month_start(date(),1) with system date set to 02/01/2006 the result is 02/02/2006 which is the second business day of the month February 2006.

The function in both cases should return the ether the 1st or the 2nd business day of thier respective months?

5. What I am attempting to do is to make work day only calendars form using the system date and the month_start function to start the begining date for each of the 20 - 22 fields for the month. But I'am not getting any consistency from the function. The holiday.dbf is setup with hollidays that match the US Post Office.

I have each field setup on initiate and it fills in the header for each work day of the month. The only difference in each function is the day of the month is the number of days to add.
and so on....

I did a small example of what I am getting as results. from the add_bus_days funtion.

Using this function add_bus_day(month_start(date(),1) with system date set to 01/01/2006 the result is 01/02/2006 which is the first business day of the month January 2006.

Using this function add_bus_day(month_start(date(),1) with system date set to 02/01/2006 the result is 02/02/2006 which is the second business day of the month February 2006.

The function in both cases should return the ether the 1st or the 2nd business day of thier respective months?

I did some more diagnostics and futher found that the function almost works when you start the function with 0 add on days. It does for February 2006 but not for January 2006

6. Using this function add_bus_day(month_start(date(),1) with system date set to 01/01/2006 the result is 01/02/2006 which is the first business day of the month January 2006.

Using this function add_bus_day(month_start(date(),1) with system date set to 02/01/2006 the result is 02/02/2006 which is the second business day of the month February 2006.

The function in both cases should return the ether the 1st or the 2nd business day of thier respective months?
I don't accept your premise. These functions don't test whether the first day of the month is itself a business day. All they do in your expressions is begin with the first day of the month, and then add one business day. They seem to be working as intended. Either you need to account for the fact that the first day of the month is or is not a business day, or I guess I need to learn what I'm missing.

why not start with the last day of the previous month ?

Alternatively, why not step through all the days of each month discarding those that are not business days ?

-- tom

7. Originally Posted by reedorbs
What I am attempting to do is to make work day only calendars form using the system date and the month_start function to start the begining date for each of the 20 - 22 fields for the month. But I'am not getting any consistency from the function. The holiday.dbf is setup with hollidays that match the US Post Office.

I have each field setup on initiate and it fills in the header for each work day of the month. The only difference in each function is the day of the month is the number of days to add.
and so on....

I did a small example of what I am getting as results. from the add_bus_days funtion.

Using this function add_bus_day(month_start(date(),1) with system date set to 01/01/2006 the result is 01/02/2006 which is the first business day of the month January 2006.

The function in both cases should return the ether the 1st or the 2nd business day of thier respective months?

I did some more diagnostics and futher found that the function almost works when you start the function with 0 add on days. It does for February 2006 but not for January 2006

I responded to your private message separately but for anyone else who is interested, the add_bus_days() function explicitly prohibits the use of zero as the second parameter so I am not surprised by the inconsistency.

I am struggling with the question at hand.

Using this function add_bus_day(month_start(date(),1) with system date set to 01/01/2006 the result is 01/02/2006 which is the first business day of the month January 2006.
January 2, 2006 is a Monday which is the first business day after Jan 1, 2006 - we're right here.

Using this function add_bus_day(month_start(date(),1) with system date set to 02/01/2006 the result is 02/02/2006 which is the second business day of the month February 2006.
Feb 2, 2006 is a Thursday, the first business day after Feb 1, 2006 so we're ok here.

The function in both cases should return the ether the 1st or the 2nd business day of thier respective months?
- should and does.

I don't see what the issue is.

8. ## The first business day of February 2006 is WED not Thursday

The first business day of February 2006 is WED.

That's the problem.

Thanks for your input, any ideas?

9. This is what I figured out to create a Monthly Work Day Calendar, and yes Zero does work on the add_bus_days function. I saw the relationship of the function changing with the first day starting on a week-end when I was explaining how the add_bus_days function was inconsistent.

'Set 'Value' property of 'Day1' .
DIM form_name as c
Dim weekday as c
if is_object(topparent.this) then
form_name = topparent.name()+".this"
else
form_name = ""
end if

weekday = cdow(month_start(date()))

IF is_one_of(weekday,"Saturday"+crlf()+"Sunday"+crlf())THEN
DELETE expression_result
topparent:Day1.value = expression_result
END IF

IF is_one_of(weekday,"Monday"+crlf()+"Tuesday"+crlf()+"Wednesday"+crlf()+"Thursday"+crlf()+"Friday"+crlf())THEN
DELETE expression_result
topparent:Day1.value = expression_result
END IF

10. For each field in the Calendar header you copy the code and then increment the previous Saturday Sunday Add_Days by 1 or matching it to the number of the work day in the month as well as incrementing the Monday - Friday Add_days by 1 which will always be 1 less than that of the previous.

11. Originally Posted by reedorbs
For each field in the Calendar header you copy the code and then increment the previous Saturday Sunday Add_Days by 1 or matching it to the number of the work day in the month as well as incrementing the Monday - Friday Add_days by 1 which will always be 1 less than that of the previous.
I think you solved your issue. Here's a function which returns a crlf() delimited list of business days in the month of any given date, I think.

Code:
```FUNCTION bus_list AS C (seed AS D )
dim st as n
dim nd as n
dim day_before as d
dim bus_days as c
st = day(month_start(seed))
nd = day(month_end(seed))
day_before = month_start(seed)-1
bus_days = ""
for i = st to nd
end if
next i
bus_days = stritran(bus_days,",","",1,1)
bus_list = stritran(bus_days,",",crlf())
END FUNCTION```
Sample output

Code:
```? bus_list({01/01/2006})
= 01/02/2006
01/03/2006
01/04/2006
01/05/2006
01/06/2006
01/09/2006
01/10/2006
01/11/2006
01/12/2006
01/13/2006
01/16/2006
01/17/2006
01/18/2006
01/19/2006
01/20/2006
01/23/2006
01/24/2006
01/25/2006
01/26/2006
01/27/2006
01/30/2006
01/31/2006```

12. Cool, Thanks,

I did solve my own results, but still not sure that the function add_bus_days works properly between months.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•