Hi friends,
I am assigning API datetime value to a string like the below in our .net core project.
string strdate = Convert.ToString(token["Receipt Date"]) + " " + Convert.ToString(token["Transaction Time"]);
I am inserting into the table like the below.this worked these many days without fail.
cmd.Parameters.AddWithValue("@Saledatetime",Convert.ToDateTime(strdate));
But now when I am using Convert.ToDateTime(strdate) it is giving the value {2023-11-27 12:41:04}.
So getting the error while insertion.In the string it is coming value 2023-11-27 12:41:04 Why the curly braces { } coming fter converting string to datetime.
Please tell me how to resolve this?
Amit MohantyPosted Nov 28, 2023, 8:59 AM
Check the demo here: https://www.mycompiler.io/view/JJqMRJUpI4d
prasanna pPosted Nov 28, 2023, 8:08 AM
hi Amit Mohanty,
Getting the same error.
The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
The statement has been terminated.
In the parsedDateTime field have value {2023-11-27 12:41:04}
Amit MohantyPosted Nov 28, 2023, 7:59 AM
Try this: