Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Anyone have a AfterFirstBusDayOf Month function?
Message
From
16/01/2003 12:54:27
 
 
To
16/01/2003 12:04:46
Bill Drew
Independent Consultant
Chicago, Illinois, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00742471
Message ID:
00742512
Views:
20
Bill,

September is also a special case. Something like this will work, of course it can be shortened by iif() and finding common cases...

I did not test all cases.
lparameters inDate

    local ldFirstDayOfMonth, ldFirstBusinessDay

    ldFirstDayOfMonth = date(year(inDate),month(inDate),1)

    do case
        case month(inDate) <> 1 and month(inDate) <> 9
            do case
                case dow(ldFirstDayOfMonth) = 1
                    ldFirstBusinessDay = ldFirstDayOfMonth + 1
                case dow(ldFirstDayOfMonth) = 7
                    ldFirstBusinessDay = ldFirstDayOfMonth + 2
                otherwise
                    ldFirstBusinessDay = ldFirstDayOfMonth
            endcase
        case month(indate) = 1  && January
            do case
                case dow(ldFirstDayOfMonth) = 1
                    ldFirstBusinessDay = ldFirstDayOfMonth + 1
                case dow(ldFirstDayOfMonth) = 7  && Some places may consider Monday
	                                 && a non-business day in this case?
                    ldFirstBusinessDay = ldFirstDayOfMonth + 2
                case dow(ldFirstDayOfMonth) = 6  && New Years on Friday
                    ldFirstBusinessDay = ldFirstDayOfMonth + 3
                otherwise
                    ldFirstBusinessDay = ldFirstDayOfMonth + 1
            endcase								
        case month(indate) = 9  && September
            do case
                case dow(ldFirstDayOfMonth) = 2
                    ldFirstBusinessDay = ldFirstDayOfMonth + 1
                case dow(ldFirstDayOfMonth) = 1
                    ldFirstBusinessDay = ldFirstDayOfMonth + 2
                case dow(ldFirstDayOfMonth) = 7  
                    ldFirstBusinessDay = ldFirstDayOfMonth + 3
                otherwise
                    ldFirstBusinessDay = ldFirstDayOfMonth
            endcase
    endcase
	
    return (inDate > ldFirstBusinessDay)  && change to >= if you want first business day
                                          && to return true

endproc
>If we assume the January is the only month that can be exceptional, can you give me a logical construct to know if x date after the first business day of the month.
>
>I have been using something like this. But the blood sugar must be low cause i need a little help. Getting confused with Jan.
>
>
>LPARAMETERS indate
>LOCAL lAfterFirBusDay
>DAYOFWEEK = DOW(indate-DAY(indate)+1)
>DO CASE
>CASE DAY(indate) = 1
>	lAfterFirBusDay = .f.
>CASE dayofweek = 2 AND DAY(indate) < 4
>	lAfterFirBusDay = .f.
>OTHER
>        lAfterFirBusDay = .t.
>endc
>retu lAfterFirBusDay
>
>
Steve Gibson
Previous
Reply
Map
View

Click here to load this message in the networking platform