07-19-2013 04:31 AM
Do anyone know how to get a variant value to string and back to variant?
07-19-2013 05:22 AM - edited 07-19-2013 05:25 AM
Well there is no generic way to do the latter. A string looses all information about the initial datatype so if you see "123" this could mean it was a string all along already or it could be an integer, or even a floating point with 0 as fractional part. Or it could have been an enum. Without providing some extra information to the String to Variant data as to the expected type, there is simply no solution.
And things get really interesting if you talk about such things as timestamps. Unless you require the string to be in a locale independant format like ISO 8601, you can at best throw your hands in the air in trying to find an automatic method to reliably translate a string back into a timestamp. 7/1/2013 could mean January 7, or July 1, depending in what local (and possibly locale customized format) the string was created. Not to forget that some regions prefer 1.7.2013 and a few other separation characters and order of elements. Deducing the order from the seperator is only a bandaid, but not a secure algorithme.
12-10-2021 02:32 PM
He's how I did it.