Microsoft KB Archive/99618

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a
 * Microsoft FoxPro for Windows, versions 2.5, 2.5a
 * Microsoft FoxBASE+ for MS-DOS, version 2.1
 * Microsoft FoxBASE+ for Macintosh, version 2.01

-

SYMPTOMS
When comparing date fields and character strings so that the results of the comparison reflect a given range of dates, the comparison must be done by using the CTOD command, rather than using the DTOC command.

MORE INFORMATION
Consider the following code:

date_fld=03/01/93 && An actual date field. comp_str=&quot;04/01/90&quot; && The string to compare.

BROWSE FOR DTOC(date_fld)>comp_str The BROWSE command above does not return 03/01/93 as being greater than 04/01/90 because the strings are compared from left to right and the month takes precedence in a straight string comparison regardless of the year. To obtain the correct result, the strings must be compared as date to date rather than string to string. To perform this type of comparison, modify the BROWSE command to read as follows: BROWSE FOR date_fld>CTOD(comp_str) This type of BROWSE command ensures the year is compared before the month, and therefore the desired results are returned. Additional query words:

Keywords         : kbGrpFox FoxDos FoxWin FxprgBrowse Version          : MACINTOSH:2.01; MS-DOS:2.0,2.1,2.5,2.5a; WINDOWS:2.5,2.5a Platform         : MACINTOSH MS-DOS WINDOWS Issue type       : kbprb
 * }