Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Code to find all invalid dates
Message
De
28/06/2013 13:40:09
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 8
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01577415
Message ID:
01577417
Vues:
76
>How do write a code that goes through all my database table looking for invalid dates residing
>in the tables? I need it to list the table name, field name and the invalid date.

What constitutes an invalid date? If VFP throws an error using it, then:
lnTables = ADBOBJECTS(laTables, "TABLE")
FOR lnI = 1 TO lnTables
    USE (laTables[lnI]) ALIAS myTable

    * For a specific date, use TYPE().
    * To find all date fields, put an inner loop below to go FOR lnJ = 1 to FCOUNT() and use FIELD() to get each name and type, and test each date found
    IF TYPE("myTable.dDateField") = "D"
        SCAN
            TRY
                lcDateTest = DTOC(myTable.dDateField)
        
                * OR:
                *REPLACE dDateField WITH dDateField IN myTable
        
            CATCH
                ? "Bad date on RECNO(): " + TRANSFORM(RECNO())
            ENDTRY
        ENDSCAN
    ENDIF
    USE in myTable
NEXT
If a bad date is outside of a valid range for the accounting year, etc., then you would use logic.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform