String converter cannot convert from Datetime

studio

#1

Hi, I have a excel sheet which has a “Date of Birth” column with values such as “1977-11-02 00:00:00.0”. The robot machine’s datetime format is MM/dd/yyyy which kept the column in General format in Excel.

What I was trying to do was to get row value and write a log message, and I’ve set the output of the value to variable type string. But this particular row “1977-11-02 00:00:00.0” has been throwing me “String converter cannot convert from Datetime” error while writing log message but worked for other rows such as “1988-08-16 00:00:00.0”.

I get that if I set output variable type to generic value and add .ToString at log message would have solved this. But I would like to know why it worked previously and doesnt for this case.


#2

when you read it from Excel it will not always convert the extracted value as String Since the type in Excel is generic this is the common issue, in Message box you should explicitly convert that to string as dobString.ToString


#3

But may I ask why only this case didn’t work?
The value itself which ended in .0 (no reasonable datetime format) is entered this way to prevent auto datetime detection by Excel.

Additionally, I didn’t mention previously that the cell value was actually a vlookup formula from another excel, in which we have specified that the column to be looked up is definitely in text format.

The reason why we set dobstring variable type to string and not generic value is to prevent it to do any alterations between conversion from generic value to string during .ToString conversion.


#4

But may I ask why only this case didn’t work?
The value itself which ended in .0 (no reasonable datetime format) is entered this way to prevent auto datetime detection by Excel.

Additionally, I didn’t mention previously that the cell value was actually a vlookup formula from another excel, in which we have specified that the column to be looked up is definitely in text format.

The reason why we set dobstring variable type to string and not generic value is to prevent it to do any alterations between conversion from generic value to string during .ToString conversion.