-1

In MySQL am getting error for above. Error is : Incorrect datetime value '31/July/2018' for function str to date

Update mytable
set Date1 = STR_TO_DATE('31/July/2018', '%d/%b/%Y')
where 'Date' IS NOT NULL; 

Need help with what could be wrong with above.

user10319580
  • 31
  • 1
  • 1
  • 1

1 Answers1

1

The issue is the %b:

%b Abbreviated month name (Jan to Dec)

You need %M:

%M Month name in full (January to December)

Source: https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date

Salman A
  • 262,204
  • 82
  • 430
  • 521
maio290
  • 6,440
  • 1
  • 21
  • 38
  • 1
    Atleast link to official mysql docs https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date format is explained here https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format – Raymond Nijland Oct 26 '18 at 14:12
  • 1
    Re source: there are people who know how these functions are supposed to work, and there are people who simply copy the stuff. You decide. – Salman A Oct 26 '18 at 14:23
  • @maio290 Some people [don't like w3schools](https://meta.stackoverflow.com/questions/280478/why-not-w3schools-com), there was even a dedicated website called [w3fools](https://www.w3fools.com/) listing all the faults there – Alon Eitan Oct 26 '18 at 14:33