- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @dypro. I finally revisited this again today, and I tried something a bit different. The big problem with trying to convert an unknown String into a true Date type, is that you sort of need to know what format the String is already in ahead of time. If you do not know how the String is laid out or formatted, it is a a guessing game, and the data type conversion might either fail, come out not correct/ not accurate. In this version, I tacked the possibility of the sValue being either empty, or simply not convertable to a Date, at the top of the loop. Then I created the 'oDate' variable as a Date data type, and since a variable of that type can not have its value nullified, I set its initial value to its minimum value (beginning of the day, year 0000). Then I try to convert the sValue String type data to a Date to set as the value of that oDate variable, using the local 'culture' info from your computer when you run the code. I can only hope that will be accurate. Then I simply try to use that oDate variable down within those two Case statements below that need a Date type value. Either way, it should set a value as a Date, but the date may be wrong if it had trouble converting.
I attached a text file to this response containing the modified code. I basically copied the last full code from above in this post, then modified it as seemed logical to me right now. I hope this works better for you.
Wesley Crihfield
(Not an Autodesk Employee)