I have created table named as schedule in mysql, having 3 columns CREATE TABLE SCHEDULE ID int(11), FromDate TIMESTAMP, TODATE TimeSTAMP); insert into schedule(id,fromdate,todate) values (1,'2012-08-12 10:30:00','2012-08-15 18:17:00'); Code (markup): what I am trying is to find out record which comes in between given time such Select Count(*) from Schedule where fromdate>='2012-08-12 10:30:00' and todate<='2012-08-15 19:17:00'; Code (markup): The above query suppose to return zero but it returning one that means something I am doing wrong to find out the number of records come between given times Please help me out to solve this issue . Looking forward to your kind response Regards M.A.Bamboat
right 2 things firstly you need to be more consistent. mysql is case sensitive and a table SCHEDULE is different from schedule. The same with columns. secondly the query does exactly what you say. the dates that you are inserting into the db are equal to the ones in your query. if you change the the from date to be further in the past ie 2012-08-12 09:30:00 or the to date to a later date ie 2012-08-16 19:17:00 you will see that you will get 0 as result.