Error converting data type nvarchar to datetime2

Using a ExeuteNonQuery to call a stored procedure, it does not want to convert my datetime variable, even if i pass it as datetime or a pure string.

I even tried passing it in the exact format that i can see in the Database - still i get the Error converting data type nvarchar to datetime2.

I’m using windows VB and Database activities 1.7.1
Anyone have any ideas? the format in the SQL database for the specific colum are 2024-07-01 00:00:00.0000000

@jeppe_jakobsen

May be pass it as string and then in your stored proc use the string with datetime conversionand check

Cheers

Hmmm, i have a trycast on in the stored procedure.

If i grab the exact datetime string that i use, and try to use that in a execute prodcedure in SQL management studio, it accepts the string as it is.

Does UiPath do something to the variable before it runs the procedure

1 Like

@jeppe_jakobsen

may be the special characters in the string might be creating issue also…cannot say exactly what it is…try to check on exception details in locals panel if it shows any other info

normally…we send the datetime as string and then cast it in sql and that way never saw an issue

also with datetime format with standard sql formatting also did not see an issue…but based on stored proc or due to upgrades there might be changes as well

so better to go with cast itself and try avoiding any special characters…or to verify create a dummy table and string column and pass date as string and check how it looks

cheers

Hi @jeppe_jakobsen

Please also validate with Database 1.9.0. There is a big jump in dependencies between the two versions, and it could be that the issue comes from the driver and was actually fixed by said dependency upgrade.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.