470,573 Members | 1,619 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,573 developers. It's quick & easy.

Select query between a few hours.

137 100+
Hello guys,
I'm busy writing a website for dj's.
But i wanted to show the picture and more stuff of the dj who's playing music between a few hours.
Let's say he works between 18:00 and 21:00 on wednesday.
I created a table begin_time and a table end_time and day.
Then i wanted to compare the times with the local time like[PHP]$time = date("H");[/PHP]
[PHP]$day = date("l");[/PHP].
I thought something like this query:

[PHP]$query = "SELECT * FROM dj WHERE day='{$day}' AND begin_time='{$time}'=BETWEEN begin_time AND end_time";[/PHP].

But i can't figure it out....
The problem is that the time only compares at that hour (eg 18:00 and 21:00) but when it is 20:00 he doesn't recognize it.(logical of course...)
But how can i let it work like this...

Thanx in advance!

Paul
May 23 '07 #1
1 3344
pbmods
5,821 Expert 4TB
Hello guys,
I'm busy writing a website for dj's.
But i wanted to show the picture and more stuff of the dj who's playing music between a few hours.
Let's say he works between 18:00 and 21:00 on wednesday.
I created a table begin_time and a table end_time and day.
Then i wanted to compare the times with the local time like[PHP]$time = date("H");[/PHP]
[PHP]$day = date("l");[/PHP].
Take a look at CURDATE() and CURTIME(). You can also use NOW(), which returns a timestamp, so you can use it for both dates and times.
May 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by George | last post: by
3 posts views Thread by Tcs | last post: by
4 posts views Thread by Stephen Young | last post: by
1 post views Thread by davidboyd24 | last post: by
1 post views Thread by Rob Woodworth | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.