Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date type
Message
From
09/12/2016 03:49:18
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01644735
Message ID:
01644756
Views:
74
Likes (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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform