How to Index a Combined Date and Character Field

ID: Q97066

2.01 2.50 | 2.00 2.50 | 2.00 2.50 3.00

MACINTOSH | MS-DOS    | WINDOWS
kbprg

The information in this article applies to:

To create an index on combined Date and Character type fields, you must break the Date type field into separate year, month, and day components; use the STR() function to connect the date pieces in the correct order; and then add the Character type field to the date string.

You can use the following examples to create an index on combined Date and Character type fields (the INVOICES database is referenced in the examples):

   INDEX ON STR(YEAR(idate))+STR(MONTH(idate))+STR(DAY(idate))+cno TO
   "date_cno.idx"

   -or-

   INDEX ON DTOC(idate, 1)+cno TO "date_cno.idx"

   -or-

   INDEX ON DTOS(idate)+cno TO "date_cno.idx"

NOTE: The third example above applies ONLY to FoxPro versions 2.0 and later (including FoxPro for Macintosh), not to FoxBASE+.

REFERENCES

"Microsoft FoxBASE+ Commands & Functions," page 4-22 "Microsoft FoxPro Language Reference," version 2.5, page L3-473

Additional reference words: VFoxWin 3.00 FoxWin FoxDos FoxMac 2.00 2.01 2.50 index cross- platform KBCategory: kbprg KBSubcategory: FxprgGeneral

Keywords          : FxprgGeneral 
Version           : 2.01 2.50 | 2.00 2.50 | 2.00 2.5
Platform          : MACINTOSH MS-DOS WINDOWS

Last Reviewed: April 30, 1996