Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I validate if a value is a valid date?
Message
De
11/01/2004 10:07:14
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
11/01/2004 09:54:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00865825
Message ID:
00865826
Vues:
17
>I have searched for something like isdate() or similar function, but can't find any.
>So, how can I find if xValue is a valid date?
>I'm trying to write a function that translates any valid date to an easily read date value in Spanish, like 3/Ene/2004
>So far I managed to make the default value of a field = to convertdate(date()), but what if the user wants to write a different date and it happens that is not a valid date? Also I want the function to check for this, instead of having to write code for every date field in my application. Yes, it is in a very advanced state, and I thought of this just now.

I will assume DMY date format.
? not empty(ctod("11/13/2004"))
...will return .F., since there is no month #13. For a valid date, this will return .T.

If you use VFP 6 or later, you may also have to temporarily SET STRICTDATE to a lower value.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform