Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date type
Message
De
09/12/2016 03:49:18
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
01644735
Message ID:
01644756
Vues:
75
J'aime (1)
>I am just about completing a fairly extensive import utility of CSV files, and have a potential concern about this type of date found as a character (I was thinking there was a built in VFP way to make this conversion, but can't remember what it was) :
>
>December 12, 2016 or Dec. 12, 2016
>
>If I allow a user to select the above as a Date field, I need to convert it to a normal 12/12/2016 which is stored as a date field in the table. Anyone know the best way to do this? I will not know ahead how the date is stored and will be testing it before appending it to the actual date field in the table.

I would
(1) Get all possible formats - eg as well Dec 12, 2016, 12/12/2016, 12-12-2016, etc
(2) Write a class that uses regular expressions one per format, and a method per format to convert to a date

That way, you can expand it later if another format turns up
You can use a collection, each member having
- the regex pattern
- the regular expression object
- a method ( name) to call if the regex matches - you can pass the matches collection to the method

Then it's just a matter of looping through the collection
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform