mysql Select record between times

Hi All,

I am having trouble understanding how to query based on 2 times.

I am trying to define "What's Next", based on the current time   date("G:i")   and pull the relevant record.

Hope you can help! Many thanks in advance,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
universalmonsterAuthor Commented:
Thanks Icohan.

I think my trouble is because i'm trying to display the next record.

For example, if there is a meeting between 12:00 and 12:30 and another at 12:30 to 13:00 - should the time be 12:15, I need it to show the 12:30 record.
lcohanDatabase AnalystCommented:
In that case use I would just add a WHERE clause to the select like:

WHERE starttime > NOW()

and this should give all "next" records/events starting after the current date/time.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
universalmonsterAuthor Commented:
When you put it like that, it looks too easy. I think I was over complicating it. Thank You!

SELECT * FROM timetable WHERE starttime > "09:31" ORDER BY starttime LIMIT 1;

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.