InterviewSolution
Saved Bookmarks
| 1. |
How to change the data type of requireDate field in query |
|
Answer» SELECT orderNumber, requiredDate FROM orders WHERE requiredDate BETWEEN '2018-01-01' AND '2018-01-31'; The query SELECTS orders WHOSE required dates are in January 2018. The data type of the requireDate COLUMN is DATE, therefore, MySQL has to convert the literal strings: '2018-01-01' and '2018-01-31'into TIMESTAMP values before EVALUATING the WHERE condition. SELECT orderNumber, requiredDate FROM orders WHERE requiredDate BETWEEN CAST('2018-01-01' AS DATETIME) AND CAST('2018-01-31' AS DATETIME); |
|