Re: Has the 5th business day of the month passed???
Re: Has the 5th business day of the month passed???
- Subject: Re: Has the 5th business day of the month passed???
- From: email@hidden
- Date: Wed, 21 Feb 2001 15:39:03 EST
Jason,
There is always a better way!
But first, your script will fail in January and July, and sometimes in
September, because it doesn't account for holidays (New Years Day,
Independence Day, Labor Day).
Second, it seems a little silly to have as a loop parameter "until
businessDayOfMonth is 5" when inside the loop you test that condition and
then set fifthBusinessDay to true. Better to use fifthBusinessDay as your
loop parameter.
Third, todayDate and currentDate are very confusing. One would easily assume,
as I did, that they are the same value, and they are not. Why not just test
for (nth = day of currentDate)?
Jeff Baumann
email@hidden
www.linkedresources.com
12 Days, 3 Hours, 45 Minutes
How is it going to end?
In a message dated 2/21/01 1:06:50 PM, Jason Bourque wrote:
>
Hello,
>
>
I need to confirm that the fifth business day of the month has passed before
>
continueing on with a script.
>
I have done it successfully but I ask is there a better way.
>
>
here's my code
>
>
>
--Reference list for comparing days of the week
>
set businessDayList to {"Mon", "Tue", "Wed", "Thu", "Fri"}
>
>
--This variable is used to toggle the printcode update flag
>
set fifthBusinessDay to false
>
>
--This variable is used to count the business days in the month
>
set businessDayOfMonth to 0
>
>
--This variable is used to hold the current date
>
set currentDate to (current date)
>
>
--This variable is used to walk thru the days of the month
>
--Copy is used instead of set to avoid data sharing between the variables
>
copy currentDate to todayDate
>
>
--Change the day to the first day of the month
>
set day of todayDate to 1
>
>
--This variable is used as the repeat loop counter
>
set nth to 1
>
>
--Repeat until five business days are passed or we reach today date
>
repeat until businessDayOfMonth is 5 or (day of todayDate) is (day of
>
currentDate)
>
>
--Get the day of today date
>
set dayOfToday to text 1 thru 3 of (todayDate as string)
>
>
--Check if day of today is in the reference list
>
if dayOfToday is in businessDayList then
>
>
--Add a day to the business day counter variable
>
set businessDayOfMonth to businessDayOfMonth + 1
>
>
--Check business day counter has reached five days
>
if businessDayOfMonth = 5 then
>
>
--Toggle the printcode update flag
>
set fifthBusinessDay to true
>
end if
>
end if
>
>
--Increase the repeat loop counter by 1
>
set nth to nth + 1
>
>
--Change the day to the to match the counter
>
set day of todayDate to nth
>
end repeat
>
>
fifthBusinessDay