I have different fields with month week and day, i want to convert fields to date. Year is current year. The current table format and value's below.
Current table
----------------------------
| ID | Month | Week | Day |
----------------------------
| 1 | 11 | 2 | 4 |
| 2 | 09 | 3 | 5 |
| 3 | 12 | 2 | 2 |
| 4 | 12 | 4 | 5 |
----------------------------
eg 3 record : year - 2018, Month - 11, Week - Second, Day - 2(Tuesday) convert into : 2018-11-05.
Output like below
---------------------
| ID | Date |
---------------------
| 1 | 2018-11-07 |
| 2 | 2018-09-06 |
| 3 | 2018-12-13 |
| 4 | 2018-12-29 |
---------------------
SELECT STR_TO_DATE(concat("2018",Month,Week(week))) from schedule
I tried the select query DAYOFWEEK and WEEK those only use for date. My process reverse.
Table
CREATE TABLE `schedule` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`month` int(2) DEFAULT NULL,
`week` int(2) DEFAULT NULL,
`day` int(2) DEFAULT NULL,
)