Skip to content
Advertisement

Incorrect parameter count in the call to native function ‘str_to_date’

There is a table tab1:

when I used str_to_date(), I had this uncorrect result and errors.

Query:

logs:

The question is How can I get this result:

MySQL version is 8.0.23

Advertisement

Answer

If you just want the year, why not use a substring operation? After all, you’re storing the value as a string:

In the meantime, you should fix your table so it stores date/time values using the correct data type.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement