#196491 - 2009-10-27 04:06 PM
Re: business day based test
[Re: sroux]
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
|
A quick and dirty way would be something liek this. The downside of this quick and drity fix is that you need to enter all second workday dates.
$dates = "2009/01/02","2009/02/03","2009/03/03","2009/04/02","2009/05/05","2009/06/02" +
"2009/07/02","2009/08/04","2009/09/02","2009/10/02","2009/11/03","2009/12/02"
If AScan($dates, @DATE)
;Do stuff
Else
;Do nothing
EndIf
Edited by Mart (2009-10-27 04:07 PM) Edit Reason: Removed long line.
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
Top
|
|
|
|
#196493 - 2009-10-27 04:48 PM
Re: business day based test
[Re: Mart]
|
sroux
Fresh Scripter
Registered: 2009-06-01
Posts: 6
Loc: France
|
I think indeed that the best solution is to manage it through a quick and dirty script as I tried the following but its non sense!
$bday = "monday", "tuesday", "wednesday", "thursday", "friday"
If AScan($bday, @Day)
; Business day/Workday
If @MDayNo = 2 ;That is false
; Business day/Workday
? "2nd business day : @Day - @MDayNo - @Date"
Else
? "not 2nd business day : @Day - @MDayNo - @Date"
Endif
Else
? "not a business day / workday : @Day - @MDayNo - @Date"
Endif
|
Top
|
|
|
|
#196505 - 2009-10-28 11:48 AM
Re: business day based test
[Re: Richard H.]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4381
Loc: New Jersey
|
I based my reply on the fact that the OP created an array called "$BD" (BusinessDay), and the lack of any holiday-type logic in his code.
Holidays aside, if we're looking for the second business day of the month, it's pretty limited logic - it can only be the second, through the fourth, depending on whether the first is on a Friday/weekend or not.
If the first was a Friday, the second day is Monday following, If the first is on Saturday, or Sunday, the second business day is the Tuesday that follows. Otherwise, it is the second day of the month.
Thus, Select
; First was Friday - SBD is Monday
Case @WDAYNO = 2 And @MDAYNO = 4
DoSecondBusDay()
; First was Sat or Sun - SBD is Tuesday
Case @WDAYNO = 3 And @MDAYNO = 4 or @MDAYNO = 3
DoSecondBusDay()
; First is Mon-Thur, today is the second day of the month
Case @MDAYNO = 2
DoSecondBusDay()
EndSelect Of course, if holidays must be accounted for, than a simple 12-line INI file would get the job done.[SBD_OF_MONTH]
2009/01/02=1
2009/02/03=1
2009/03/03=1
2009/04/02=1 lists the dates that represent the second business day each month. The value is unimportant, it just holds a non-zero value. The code is reduced to If ReadProfileString('.\dates.ini', 'SBD_OF_MONTH', @DATE)
; it's the second business day!
EndIf The code will return false unless the current date is found in the dates.ini file. Of course, you could use a combination of methods, using the lookup as the first attempt in the Select statement. This way, the dates.ini file only holds holiday exceptions, which are more difficult (but not impossible) to calculate.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 329 anonymous users online.
|
|
|