KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q97066: HOWTO: Index a Combined Date and Character Field

Article: Q97066
Product(s): Microsoft FoxPro
Version(s): MACINTOSH:2.5; MS-DOS:2.0,2.5; WINDOWS:2.0,2.5,3.0,5.0,6.0
Operating System(s): 
Keyword(s): kbDSupport
Last Modified: 03-MAR-2000

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual FoxPro for Windows, versions 3.0, 5.0, 6.0 
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5 
- Microsoft FoxPro for Windows, versions 2.0, 2.5 
- Microsoft FoxPro for Macintosh, version 2.5 
-------------------------------------------------------------------------------

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.

Additional query words: index cross-platform

======================================================================
Keywords          : kbDSupport 
Technology        : kbHWMAC kbOSMAC kbVFPsearch kbAudDeveloper kbFoxproSearch kbZNotKeyword3 kbFoxPro200DOS kbFoxPro250DOS kbFoxPro250 kbVFP300 kbVFP500 kbVFP600
Version           : MACINTOSH:2.5; MS-DOS:2.0,2.5; WINDOWS:2.0,2.5,3.0,5.0,6.0
Issue type        : kbhowto

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.