I have a table called test
in my MySQL database. Below is the how it is created.
CREATE TABLE `test` (
`update_date` varchar(10) NOT NULL,
`value` double NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Below is its data.
I run the below query as described in the selected answer of here
SELECT SUM(`value`) FROM `test`
WHERE STR_TO_DATE(`update_date`, '%d-%m-%Y') BETWEEN '01-10-2014' AND '31-10-2014'
This should return 1800, but instead it returned NULL
. Why is this and how can I get the correct answer?
Very Important: I have to use String
for Date
because I must save date in dd-mm-yyyy
format and mysql Date
do not accept it.