Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

indexing on two different fields 1

Status
Not open for further replies.

kate

Programmer
Nov 19, 2001
51
0
0
US
I have a table that I want to create an index for on two fields. I want the table to be ordered by a name field with field type of char and then by a expir_date field with type of date, however I want the name field to be ascending and the date field to be descending.

I've tried creating to different tag names and calling them both at the same time, but I get a "operator/operand type mismatch error". So I tried using the expression dtos(expir_date) and then calling calling both indexes but I get the same error.

Is there a way to make one of the fields ascending and the other descending? I know I could use the sort command, but I want to be able to open this table with an index.
 

Would I be right in suggesting the use of a UDF?
One which saved the current date settings and restored them?


Thanks, I know, I don't really need it so much. For newer applications, I just open a new instance of VFP and set strictdate right from the start (either in startup or in main program). Even then, I don't use strictdate so often - even though it was the recommended way from the moment when it first appeared. Habits are a strong force. Maybe closer to the year 10000 problem, I think.

All seems a bit clumsy - I'll use the ctod() route personally!
A matter of taste then. I don't say my way is perfect, and can suggest a few other ways, too, but for me, STR(CTOD()) seems clumsy (but acceptable when necessary). And I would prefer to use 3000/01/01 - I like it better. VFP doesn't seem to reject it, too.
 
I would not use a UDF. The program will be needed even to USE the table from the Command Window.

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top