How to Modify the Results of the MDY() FunctionLast reviewed: March 20, 1998Article ID: Q145605 |
3.00 3.00b | 2.60a
WINDOWS | MACINTOSHkbprg kbhowto kbcode The information in this article applies to:
SUMMARYWhen the day of a month is between the first and the ninth, the MDY function returns the date with a zero (0) in front of the day. This article gives you a program that removes the zero (0) from the results of the MDY format.
MORE INFORMATIONNormally, a date in the form of month/day/year does not have a zero in front of a day. The MDY() function always places a zero in front of single-digit days. The program listed in this article uses the functions MDY() and STRTRAN() to remove the blank space and zero and replace it with only a blank space. The program searches the value returned from the MDY() function for a blank space followed by a zero. If it finds this combination, the STRTRAN() function replaces it with a blank space. WARNING: The MDY() function changes the data type of the variable from a date type to a character type so that the unwanted zero can be removed. If the variable must remain as a date type, no setting or function exists to remove it. Furthermore, after modifying the format of the variable, you can't use the CTOD() functions to convert it back to its original date format. Create a program file named Test that contains the following code. Then run the program.
SET CENTURY ON x={01/01/1996} y={01/01/2000} ? MDY(x) ? MDY(y) ? STRTRAN(MDY(x)," 0"," ") ? STRTRAN(MDY(y)," 0"," ") SET CENTURY OFF |
Additional reference words: 3.00 3.00b VFoxWin 2.60a FoxMac
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |