Click here to Skip to main content
15,076,130 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i have datetime datatype if mysql database to dave date and time simultaneously in the Format
yyyy/MM/dd HH:mm:ss eg 2013-09-07 14:33:00
The data is being saved succesfully, when i retrieve it in select query filter by date yyyy/MM/dd
it returns no records. how to write the Select Query to filter data between two dates.
My Query Goes here...

C#
string str = "select IFNULL( max(complain_no),0) FROM call_log WHERE complain_date = '" + DateTime.Now.ToString("yyyy/MM/dd") + "'";
Posted
Updated 6-Sep-13 23:47pm
v2

1 solution

This is how you have to write.

C#
select IFNULL( max(complain_no),0) FROM call_log WHERE date_format(complain_date,'%Y-%m-%d') = '" + DateTime.Now.ToString("yyyy-mm-dd") + "'";
   
v2
Comments
[no name] 7-Sep-13 6:47am
   
Thank You dear, It Works Fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900