Hello everyone I am planning to create a per day backup of specific table in my database inside the database I have a table named itemsreceived and column name DateCreated the DataTypes is datetime and it has a value of (2021-01-07 08:23:26).
I what to get all the data of 2021-01-07. I have this line of code inside the form
"Select * From itemsreceived" +
"WHERE date_format(DateCreated, '%Y-%m-%d') " +
"LIKE date_format('" + datepicker1.ToString("yyyy-MM-dd") + "', '%Y-%m-%d')" + ";";
to transform it to sql statement it looks like this
Select * from itemsreceived where DateCreated Like '2021-01-07';
But when I run this code there is no result.
but when I tried adding %% that look like this
Select * from itemsreceived where DateCreated Like '%2021-01-07%';
the result came out
The Question is
How can I add this sign %% to look like
Select * from itemsreceived where DateCreated Like '%%';
from this line of code
"Select * From itemsreceived" +
"WHERE date_format(DateCreated, '%Y-%m-%d') " +
"LIKE date_format('" + datepicker1.ToString("yyyy-MM-dd") + "', '%Y-%m-%d')" + ";";
What I have tried:
I dont know how to do this right, I tried but no ones is working
"LIKE date_format('" + '%'+ date.ToString("yyyy-MM-dd") + '%' + "', '%Y-%m-%d')" + ";";
"LIKE date_format('%" + date.ToString("yyyy-MM-dd") + "%', '%Y-%m-%d')" + ";";