Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Funky cDate Conversions
Message
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
00455403
Message ID:
00455482
Vues:
30
>I have users that enter dates such as "01012001" in a date field,
>the validate method calls cDate(), which I would expect to return 01/01/2001,
>but check it out:
>
>? cDate("01012001")
>10/5/4670
>
>? cDate("010101")
>8/27/1927 ' Didn't see this one coming
>
>Star trek dates! Obviously if the dashes or slashes are in the date, it works correctly. Rather than writing my own routine to insert them, does anyone know of a quick date conversion that works correctly (or even explain the magic under the hood here?). There doesn't seem to be behind the scenes information on how VB is coming up with the results...

Insert slashes like this:
x="01012001"
? cdate(left$(x,2) & "/" & mid$(x,3,2) & "/" & mid$(x,5))
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform