Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Fine but not for contiguous date ranges
Message
From
30/10/2006 07:54:28
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01165450
Message ID:
01165467
Views:
12
Belay all this. I racked my brains on Friday over this. I've had a rethink: I tried the same code but with 2 separate selects-SQL, UNIONed - same result. I've since discovered that the problem arises with the next stage of processing:

NOTE: for testing, I reversed order of testing - prev period first and found that now it's the CURRENT period that's missing data:
Wait WINDOW "Non-ETM Data: Apportioning Passenger Numbers within the Time Periods ..." NOWAIT NOCLEAR 
Scan for not DELETED()
  llDatesInRange		= .F.
  lnNumDaysInRec		= END_DATE - START_DATE + 1
  DO CASE
    Case START_DATE <= ldStartPrev and END_DATE > ldStartPrev	&& Start date before previous date range
      llDatesInRange	= .T.
      llCurrPeriod		= .F.
      If END_DATE > ldEndPrev       && ends later than Prev period end, so all outside
          lnPrevPass	= lnNumDaysPrev / lnNumDaysInRec * PASSENGERS	&& so only ALL days curr period 
      Else	                  && ends within Prev period 
  	 lnDaysInPeriod	= END_DATE - ldStartPrev + 1	&& so only from start of Prev period to rec end date
	 lnPrevPass	= lnDaysInPeriod / lnNumDaysInRec * PASSENGERS	
      EndIf 
    Case BETWEEN( START_DATE, ldStartPrev, ldEndPrev)	&& Start date inside Previous date range
      llDatesInRange	= .T.
      llCurrPeriod		= .F.
      If END_DATE > ldEndPrev	&& ends later than Prev period end
	lnDaysInPeriod	= ldEndPrev - START_DATE + 1	&& so only from start date to end of Prev period
         lnPrevPass	= lnDaysInPeriod / lnNumDaysInRec * PASSENGERS	
      Else		         && ends within Prev period, so wholly in Prev period
  	lnPrevPass	= PASSENGERS
      EndIf 
    Case START_DATE <= ldStartCurr and END_DATE > ldStartCurr 	&& Start date before current date range
      llCurrPeriod		= .T.
      If END_DATE > ldEndCurr	&& ends later than curr period end, so all straddles
         lnCurrPass	= lnNumDaysCurr / lnNumDaysInRec * PASSENGERS	&& so only ALL days within curr period 
      Else			&& ends within curr period 
         lnDaysInPeriod	= END_DATE - ldStartCurr + 1	&& so only from start of curr period to rec end date
         lnCurrPass	= lnDaysInPeriod / lnNumDaysInRec * PASSENGERS	
      EndIf 
    Case BETWEEN( START_DATE, ldStartCurr, ldEndCurr)	         && Start date inside current date range
      llDatesInRange		= .T.
      llCurrPeriod		= .T.
      If END_DATE > ldEndCurr	&& ends later than curr period end
          lnDaysInPeriod	= ldEndCurr - START_DATE + 1	&& so only from start date to end of curr period 	 
          lnCurrPass	= lnDaysInPeriod / lnNumDaysInRec * PASSENGERS	
      Else			&& ends within curr period, so wholly in curr period
          lnCurrPass	= PASSENGERS			&& ... so count whole of rec period
      EndIf 	
  EndCASE  	
  If llDatesInRange
      If llCurrPeriod
	Replace CURRPASS with lnCurrPass
      Else
	Replace PREVPASS with lnPrevPass
      EndIf 
  EndIf 
EndSCAN 
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform