How To Index a Combined Date and Character Field (97066)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft FoxPro for MS-DOS 2.0
  • Microsoft FoxPro for MS-DOS 2.5
  • Microsoft FoxPro for Windows 2.5

This article was previously published under Q97066

SUMMARY

There are several different techniques you can use to create an index on combined Date and Character fields. The first technique illustrated below gives you a bit more flexibility in sorting. The second two are equivalent, and it is generally best to use the last example.
INDEX ON STR(YEAR(dOrder)) + STR(MONTH(dOrder)) + STR(DAY(dOrder)) + cCustID ;
      TAG dateCust
				
-or-
INDEX ON DTOC(dOrder, 1) + cCustID TAG dateCust
				
-or-
INDEX ON DTOS(dOrder) + cCustID TAG dateCust
				

REFERENCES

For more information about Date and DateTime functions, consult the Language Reference.

Modification Type:MinorLast Reviewed:7/1/2004
Keywords:kbhowto KB97066