Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DateTime Filtering weirdness
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01474873
Message ID:
01474882
Views:
47
SET FILTER condition gets evaluated every time record pointer in a table moves not at the time when SET FILTER command is issued.
Check again old code. It builds the filter condition as a string and applies it with macro substitution so it's correctly evaluated at the time of record pointer movement.

>
>I was making modifications to some old POS code and ran into this problem.....
>
>I have a table RREVENUE that has two fields in it of question.... summdate (D) and summtime( C-5) which has records like this
>
>summdate summtime
>
>07/29/10 11:00
>07/30/10 09:00
>07/30/10 15:00
>
>And I was trying to fix a filter that was being employed in the old code.....
>
>Here is the code I am modifying...
>
>
>	ldSEODBeginDate = Thisform.p_seodbegindate
>	lcSEODBeginTime = Thisform.p_seodbegintime
>	ldSEODEndDate   = Thisform.p_seodenddate
>	lcSEODEndtime   = Thisform.p_seodendtime
>
>	ltSEODBeginDate = DATETIME(YEAR(ldSEODBeginDate),MONTH(ldSEODBeginDate),DAY(ldSEODBeginDate), ;
>		VAL(LEFT(lcSEODBeginTime,2)),VAL(RIGHT(lcSEODBeginTime,2)),0)
>	ltSEODEndDate   = DATETIME(YEAR(ldSEODEndDate),MONTH(ldSEODEndDate),DAY(ldSEODEndDate), ;
>		VAL(LEFT(lcSEODEndTime,2)),VAL(RIGHT(lcSEODEndTime,2)),0)
>	lcRRevenueFilter = " (DATETIME(YEAR(summdate),MONTH(summdate),DAY(summdate),VAL(LEFT(summtime,2)),VAL(RIGHT(summtime,2))) > ltSEODBeginDate) AND " + ;
>		"(DATETIME(YEAR(summdate),MONTH(summdate),DAY(summdate),VAL(LEFT(summtime,2)),VAL(RIGHT(summtime,2))) <= ltSEODEndDate)"
>	DO CASE 
>		CASE NOT EMPTY(ldSEODBeginDate) AND NOT EMPTY(lcSEODBeginTime) AND NOT EMPTY(ldSEODEndDate) AND NOT EMPTY(lcSEODEndTime)
>			IF ldSEODBeginDate = CTOD('01/01/2010') AND lcSEODBeginTime = '00:01'
>				lcDateRange = DTOC(ldSEODEndDate) + ' - ' + lcSEODEndTime
>			ELSE 
>				lcDateRange = DTOC(ldSEODBeginDate) + ' - ' + lcSEODBeginTime + '  Thru  ' + DTOC(ldSEODEndDate) + ' - ' + lcSEODEndTime
>			ENDIF 
>		CASE EMPTY(ldSEODBeginDate) AND EMPTY(lcSEODBeginTime) AND NOT EMPTY(ldSEODEndDate) AND NOT EMPTY(lcSEODEndTime)
>			lcDateRange = DTOC(ldSEODEndDate) + ' - ' + lcSEODEndTime
>	ENDCASE 
>ENDIF 
>
>
>*Here I am just putting a test filter in .... normally it would be
>*SET FILTER TO &lcRRevenueFilter
>
>SET FILTER TO   DATETIME(YEAR(summdate),MONTH(summdate),DAY(summdate),VAL(LEFT(summtime,2)),VAL(RIGHT(summtime,2)),0) > ltSEODBeginDate
>GO TOP
>
>
>The ltSEODBeginDate is 01/01/2010 12:01:00 AM
>
>and the one record in the RREVENUE table has a summdate of 08/02/2010 and summtime of 08:28
>
>There is only ONE record in the test RREVENUE table....
>
>If I trace the code, the filter works and my one test record show up after the GO TOP.
>
>When I run the code without tracing, it fails and the record does not show up.
>
>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform