get data between two dates in php

hii all
 i want to fetch data from database between two dates.
 startdate and end_date are like (2018-04-04) and database column name datetime has a value date and time like (2018-04-04 12:05:07).
Both dates(startdate and end_date ) check with datetime column in database.
i am using query (select * from table where datetime>=startdate and datetime<=end_date). if i select both dates same like(2018-04-04 and 2018-04-04) then this query is not working. please help me how to do this?
Deepak SinghWeb DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Dave BaldwinFixer of ProblemsCommented:
Entering '2018-04-04' is the same as entering '2018-04-04 00:00:00'.  If you enter it for both dates, there can't possibly be anything between them.  Since MySQL automatically assumes the '00:00:00' part, I would use the next day for the end_date.  It would then be between '2018-04-04 00:00:00' and '2018-04-05 00:00:00' which covers 24 hours of '2018-04-04'.
2

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
NerdsOfTechTechnology ScientistCommented:
You can do exactly what @Dave said. If we knew which database you were using we could even help you with the query syntax, etc.
0
NerdsOfTechTechnology ScientistCommented:
Notwithstanding the database used, by using the day of and the next day's date for the BETWEEN parameters, a full day query can be constructed, as illustrated by Dave's comment.
0
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
Databases

From novice to tech pro — start learning today.