ID: Q108327
The information in this article applies to:
The following code example demonstrates how to use the STUFF() function to correct a date string that is in the form of a number or character so that it can be inserted in a date field or used with a date function.
   *** Code Example
   newdate = 62793                 && This is a date number without a ;
                                      leading zero
   newdate = STR(newdate)          && Converts the number into a string
   IF LEN(ALLTRIM(newdate)) = 5    && Checks to see if the character
   newdate="0"+ALLTRIM(newdate)    && string is 5 characters and adds a
   ENDIF                           && leading zero if needed
   newdate=STUFF(ALLTRIM(newdate),3,0,"/")   && inserts a / for the 3rd
                                             && character
   newdate=STUFF(ALLTRIM(newdate),6,0,"/")   && inserts a / for the 6th
                                             && character
   SET CENTURY ON
   WAIT WINDOW MDY(CTOD(newdate))
   && newdate can now be inserted in a date field of the database.
   CREATE TABLE datetemp.dbf (name C(12), fixdate D, TYPE C(10))
   APPEND BLANK
   REPLACE name WITH "It Work s!",  fixdate WITH CTOD(newdate), TYPE WITH
   "cool"
   BROWSE
   && This code closes the database and deletes it.
   IF USED('datetemp')
        USE IN datetemp
   ENDIF
   IF FILE ('datetemp.dbf')
        DELETE FILE datetemp.dbf
   ENDIF
Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a 2.50b convert
KBCategory: kbprg kbcode
KBSubcategory: FxprgBrowse
Last Reviewed: June 27, 1995