bamboat_3
bamboat_3

Reputation: 11

compare time in mysql

I have create 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');

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';

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

Upvotes: 0

Views: 1698

Answers (1)

Fathah Rehman P
Fathah Rehman P

Reputation: 8741

That query should return 1 row because you use condition as

fromdate >= '2012-08-12 10:30:00' and todate <= '2012-08-15 19:17:00'

and one record satisfies that condition

Upvotes: 1

Related Questions