Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Percentage calculation in expression of report
Message
From
30/11/2001 16:39:37
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00588031
Message ID:
00588256
Views:
43
Nadya --

When working with sets of values (days for which you may have missing data), I find using SQL SELECT to work best for me. I don't know if this would work for you or give you the results you want, but, maybe it will stimulate your thought.

Assume we're doing this for a non-leap year year (it can easily be extended).
#DEFINE    DOW_SATURDAY   7
#DEFINE    DOW_SUNDAY     1

FUNCTION   IsAHoliday
LPARAMETER        dDate
LOCAL             llIsAHoliday

    llIsAHoliday = .F.
    DO CASE
        CASE  MONTH (dDate) = 12 AND DAY (dDate) = 25
             llIsAHoliday = .T.
        CASE  etc.
    ENDCASE
    RETURN llIsAHoliday
ENDFUNC

CREATE TABLE DaysOfYear (dYearDate D, lIsWeekend L, lIsHoliday L)
ldStartDate = {12/31/1998}
FOR lnDateOffset = 1 TO 365
   INSERT INTO DaysOfYear (dYearDate, lIsWeekend, lIsHoliday) ;
       VALUES (ldStartDate + lnDateOffset, ;
           INLIST (DOW(ldStartDate + lnDateOffset, DOW_SATURDAY, DOW_SUNDAY), ;
           IsAHoliday (ldStartDate + lnDateOffset))
ENDFOR

SELECT YearDate AS dMissDate ;
    FROM DaysOfYear ;
    WHERE NOT llIsWeekend ;
          AND NOT llIsHoliday ;
          AND NOT IN (SELECT dDataDate FROM dDataTable)
HTH,

Jay


>I'm working on some application now, which is supposed to be simple, but I'm working on three days already and it still doesn't behave, as it should :(
>
>For instance, here is the peice of code, which I can not make to work correctly.
>
>The idea is to check for gaps between two days and report them excluding weekends and holidays. What's wrong with this code or how it should be changed?
>
>
>* -- Checking for missing data compared against last data received
>* -- Check for Friday or Saturday for old and new is Monday date then we're not missing any data
>		if (dow(Record_fm)=2 and Record_fm - PriorRec_To > 3) ;
>		    or (dow(Record_fm)<> 2 and Record_fm > PriorRec_To+1)
>			tmpDays = Record_fm - PriorRec_To
>			if m.tmpDays > 1
>				for i = 1 to m.tmpDays-1
>* -- Check against holiday for each missing record && Sundays & Saturdays
>					if dow(PriorRec_To+m.i)<>1 and dow(PriorRec_To+m.i)<>7 ;
>							and !seek(PriorRec_To+m.i,'Holidays')
>						lcTempStr = "May have Missing Recorded data for "+ dtoc(PriorRec_To+m.i)+"."
>						if not m.lcTempStr $ m.tmpNotesStr
>							tmpNotesStr = iif(empty(m.tmpNotesStr),'',m.tmpNotesStr+chr(13)) + m.lcTempStr
>						endif
>						llMDFlag = .t.
>					endif			&& Missing Data
>				endfor				&& Going to the next date to check for missing data
>			endif
>		endif					&& Checks for Fri or Sat and Mon
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform