Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DateTime Filtering weirdness
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
DateTime Filtering weirdness
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:
01474873
Views:
100
Hi Gang!

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.


------------------------------------------------------
UPDATE

I created a test table call TOMMY with 2 fields summdate (D) and summtime(C-5)

and copied the data over from RREVENUE to elimate any possiblity of table corruption causing this...

and I ran some filtering form the Command Prompt.
BROWSE FOR DATETIME(YEAR(summdate),MONTH(summdate),DAY(summdate),VAL(LEFT(summtime,2)),VAL(RIGHT(summtime,2)),0) > ltSEODBeginDate
works like a charm - filters out the records before 07/30/2010 04:00 PM

When I use it as a filter like so....
SET FILTER TO DATETIME(YEAR(summdate),MONTH(summdate),DAY(summdate),VAL(LEFT(summtime,2)),VAL(RIGHT(summtime,2)),0) > ltSEODBeginDate
and do a GO TOP, or SKIP

no error message yet....
but when I do

BROWSE

WHAMMO - i get this error message

FUNCTION ARGUMENT VALUE, TYPE, OR COUNT IS INVALID....

so why does it work in Browse, but fails in Filter ???

----------------------------------------------------------------------

Any ideas?

Thanks a bunch!
Tommy Tillman A+ NetWork+ MCP
Next
Reply
Map
View

Click here to load this message in the networking platform