Bug #89669 str_to_date do not return the correct first day of 2018
Submitted: 14 Feb 2018 14:11 Modified: 16 Feb 2018 17:51
Reporter: Nain Portekoi Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[14 Feb 2018 14:11] Nain Portekoi
Description:
str_to_date return an incorrect date from a string

How to repeat:
SELECT STR_TO_DATE('2018 1 Monday', '%X %V %W')

Should return 2018-01-01

But return actually 2018-01-08
[15 Feb 2018 13:32] MySQL Verification Team
Hi!

Thank you for your bug report. However, this is not a bug.

Our Reference Manual clearly states:

"

You cannot use format "%X%V" to convert a year-week string to a date because
the combination of a year and week does not uniquely identify a year and month
if the week crosses a month boundary. To convert a year-week to a date, you
should also specify the weekday:

mysql> SELECT STR_TO_DATE('200442 Monday', '%X%V %W');
-> '2004-10-18'

"

As you can see, no blanks ......
[16 Feb 2018 15:55] Nain Portekoi
If I remove the blank in the mask for the date  : 
`SELECT STR_TO_DATE('20181 Monday', '%X%V %W')`

I still have this wrong result :
==> `2018-01-08`

But If you take a calendar, you will see, first Monday in 2018 was at `2018-01-01`
[16 Feb 2018 17:51] MySQL Verification Team
Hi!

Turns out that you are right:

+----------------------------------------+
| STR_TO_DATE('20181 Monday', '%X%V %W') |
+----------------------------------------+
| 2018-01-08                             |
+----------------------------------------+

Verified.