I had try several type of date format and yet, I stil can’t get it right.
Below are the coding which had been writen
Dim serverDate As String = Format(Now(), "DD-MM-YYYY")
strNew &= "INSERT INTO Staff ("
strNew &= "full_name"
strNew &= ", login_id"
strNew &= ", passwd"
strNew &= ", last_update"
strNew &= ") VALUES ("
strNew &= "'" & txt_Name.Text & "'"
strNew &= ", '" & txt_Login.Text & "'"
strNew &= ", '" & txt_Password.Text & "'"
strNew &= ", (STR_TO_DATE('" & serverDate & "', '%d-%m-%Y'))"
strNew &= ")"
Any idea what had I missed out?.. Helps are much appreciated..
Edit #1:
Forgot to add in the error message
“Incorrect datetime value :’DD-09-YYYY’ for function str_to_date”
You are using hard-coded sql string so you need to use yyyy-MM-dd format date.
EDIT:
Yes it is incorrect format. It should be
Take a look at this code-snippet
Off-topic: Don’t use hard-coded sql string. Use parameterized sql statement.