I’m running into a problem with MySQL’s STR_TO_DATE function. For example, this code:
SELECT STR_TO_DATE("Saturday October 23 2010 11:00 AM", "%W %M %d %Y %h:%m %p");
outputs this:
2010-00-23 11:00:00
Why is everything correct except the month? Is this an error in my syntax?
You’re using the wrong modifier for minutes – use:
You specified
%m, which was overwriting the%Mvalue – see the modifiers via the DATE_FORMAT documentation. That’s why the month was coming out as zero – the modifier for minutes is%i.