Hi Sam
>
>Thanks for the info. I needed to put ctod() on my StartDate and EndDate.
>
I take it your query is now...
SELECT * FROM rejects ;
WHERE BETWEEN(daterecv,ctod(StartDate),ctod(EndDate)) ;
ORDER BY vendorname, daterecv ;
INTO CURSOR OrderRejects
Whoa!!!!
1 - CTOD() will give compiler warnings with SET STRICTDATE TO 2 - a setting you would be well advised to turn on and leave on! No need to accidentally do a y2k bug now. :)
2 - function calls inside a SQL - which is a big looping construct, so to speak, will be fired many many times, that's not the best for performance.
3 - startdate and enddate could easily be fields in a table which will cause you other kinds of troubles. If startdate and enddate are memory variables do two things to completely protect yourself. 1 - Use m. to specify a variable and 2 - Name memory variables differently from fieldnames.
4 - Before the user enters m.ldStartDate and m.ldEndDate, you should
STORE {//} to m.ldStartDate, m.ldEndDate
>SELECT OrderRejects
>GOTO TOP
5 - Although you're programming SQL in VFP, do not be tempted to mix VFP syntax with SQL syntax (unless you have no choice). It will only cause you grief when/if you query SQL Server as you will might try to use VFP function calls in those queries. Just because you can do something does not mean it's a good practice.
If you follow all of that, your query would be:
SELECT * FROM rejects ;
WHERE daterecv BETWEEN m.ldStartDate and m.ldEndDate ;
ORDER BY vendorname, daterecv ;
INTO CURSOR OrderRejects
6 - After running the query, OrderRejects is already at the TOP. You don't need GO TOP.
All of that will give you the best performance and the least amount of troubles.
HTH