General information
Category:
Coding, syntax & commands
>>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
Thanks Gregory....good idea and also good suggestion. This is a close suggestion to what I was already beginning to develop.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only