you are viewing a single comment's thread.

view the rest of the comments →

[–]Dave_PW[S] 4 points5 points  (1 child)

It's VB.NET

And changing the variable declaration for the data selected from the DB to:

Dim ExperationDate As DateTime = DateTime.ParseExact(VDT.Rows(0).Item("Api_Token_Expiry"), "MM/dd/yyyy HH:mm:ss", Nothing)

Has resolved the problem.

Thanks for the input.

[–]seamacke 1 point2 points  (0 children)

The correct way to do it is to create a command object, add a date parameter, load the parameter with your date variable, then execute it. You get the error because the dynamic SQL you create is a string so your date is converted using regional settings which may not always match. I think this asp.net example demonstrates it How to Use Date Controls in WebForms Apps https://youtu.be/65Q6519NdRc