DTOC() Returns Unexpected Results When Used with DatesLast reviewed: March 20, 1998Article ID: Q99618 |
1.02 2.00 2.50 2.50a | 2.50 2.50a
MS-DOS | WINDOWSkbprg The information in this article applies to:
SUMMARYWhen 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(<string>) command, rather than using the DTOC(<date field>) command.
MORE INFORMATIONConsider the following code:
date_fld=03/01/93 && An actual date field. comp_str="04/01/90" && The string to compare. BROWSE FOR DTOC(date_fld)>comp_strThe 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 reference words: FoxDos FoxWin 2.00 2.10 2.50 2.50a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |