I am using MySql and by standard their date format is 2019/03/31 in the database.
In my program .net, csharp i read the values into a variable as 31/03/2019, so str_date_format will not work as this only accepts - instead of /.
The strings CAN'T be hard coded in the where clause they have to be read in as parameters.
So from reading the manual i came to the conclusion that i need to use date_format with delimiters in the where clause
SELECT
DATE_FORMAT(date_time,'%d-%m-%Y'),
AVG(Total),
SUM(Total_ly),
AVG((Total + Total_ly)/2)
FROM transaction
WHERE
date_format(date_time >= @param1 , '%d-%m-%Y')
AND date_format(date_time <= @param2, '%d-%m-%Y')
GROUP BY date_time;
But its returning null for every column and it doesn't make sense because without the where clause it works fine.
I edited with more detail hope this helps, Appreciate any advice in the right direction !