Page 1 of 1

mysql time query

Posted: Wed Aug 03, 2005 6:22 am
by hame22
Hi i am trying to select records whose time fall into a certain time period.

at the moment the query looks like this

Code: Select all

select * from activities where learn_time between 01:00:00 and 03:00:00
this brings up a query error

i'm guessing that perhaps these values may need to be formatted?

I am using php as my language

any ideas???

thanks in advance

alex

Re: mysql time query

Posted: Wed Aug 03, 2005 6:46 am
by ericburnard
Try

Code: Select all

select * from activities where learn_time between '01:00:00' and '03:00:00'
that im not sure if it will work as i didnt know that there was a between function (there prob. is i just dont now :S) give it a go any way

Eric

Posted: Wed Aug 03, 2005 6:50 am
by hame22
yeah thanks but already tried that

Posted: Wed Aug 03, 2005 6:52 am
by Skittlewidth
There isn't a between. Use > (more than) and < (less than).

Code: Select all

select * from activities where learn_time > '01:00:00' and learn_time < '03:00:00'
I'm not sure about the format of your time data though. If its not stored as some kind of number this won't work.