cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Text in DateTime

RafaelGuerra
Level 2
Unable to convert supplied value to a DateTime : Text value '29/07/2021 14:32' cannot be interpreted as a DateTime

Dear, I got this message when capturing this DateTime from a table. Does anyone know how I can resolve this?

------------------------------
Rafael Guerra
------------------------------
1 BEST ANSWER

Best Answers

Hi @RafaelGuerra

Try this two thinks:

- The name of the variable that you have as output parameter is DateTime, but "DateTime" is a key word from C#. Edit the name, for example "datDateTime" in both parts, in your code and in the output tab.

- Change the language of your VBO to C#. For this, go to the Initialise Page, double clic on the properties, and go to the Code Options tab, here change the Language to C#

292.png
​​

Hope this helps you!

See you in the Community, bye 🙂

------------------------------
Pablo Sarabia
Solution Manager & Architect
Altamira Assets Management
Madrid
------------------------------

View answer in original post

3 REPLIES 3

Hi @RafaelGuerra

For this is better to use parse function.

Here you have the code to translate the text to the DateTime in your format:

datDateTime = DateTime.ParseExact(strDateTime, "dd/MM/yyyy HH:mm", null);

For my example, datTime is the DateTime data item, and strDateTime my text source, Put this in a VBO using C# and is done


Hope this helps you!

See you in the community 🙂 Saludos

------------------------------
Pablo Sarabia
Solution Manager & Architect
Altamira Assets Management
Madrid
------------------------------

291.png


Dear Pablo, would that be a suggestion?

I've never needed to do a solution like this, so I'm really confused.

When I checkcode it gives an error.

------------------------------
Rafael Guerra
------------------------------

Hi @RafaelGuerra

Try this two thinks:

- The name of the variable that you have as output parameter is DateTime, but "DateTime" is a key word from C#. Edit the name, for example "datDateTime" in both parts, in your code and in the output tab.

- Change the language of your VBO to C#. For this, go to the Initialise Page, double clic on the properties, and go to the Code Options tab, here change the Language to C#

292.png
​​

Hope this helps you!

See you in the Community, bye 🙂

------------------------------
Pablo Sarabia
Solution Manager & Architect
Altamira Assets Management
Madrid
------------------------------