954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

MySql Query For time Range in PHP

I have a MySql database that uses a time field to track when the entry was inserted.

Now I want to query the table for entries by a time range.
I would prefer to use MySql to extract the records instead of extracting all records then iterating and comparing time in php.

success on these two kinds of queries:

// this doesn't appear to be working
SELECT * FROM table_name 
WHERE DATE(TIME_ROW_START) BETWEEN '".$timestart."' AND DATE(TIME_ROW_END) BETWEEN '".$timeend."';

// this doesn't appear to be working either
SELECT * FROM table_name 
WHERE DATE(TIME_ROW_START) >= '".$timestart."'
AND DATE(TIME_ROW_END) <= '".$timeend."';


Is there a way to do this?

israillaky
Light Poster
27 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

This is related to http://www.daniweb.com/web-development/php/threads/410631/1752245

You failed to reply to that thread and started this one. Any reason?

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

This is related to http://www.daniweb.com/web-development/php/threads/410631/1752245

You failed to reply to that thread and started this one. Any reason?


Im so sorry sir for not replying.

actually sir im just trying this one and if its work
the reason that ididt reply is because i created this one for temporary purpose only if i use sql query to trap range time using time format in mysql.

if its ok with you sir

and im very sorry for not replying you. hope you understand

israillaky
Light Poster
27 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

Maybe you should stick to the same thread. Progression of an idea is a worthy *addition* to an existing thread that you started. Creating new threads and ignoring threads in progress just risks alienating contributors that offered to help you.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 
Maybe you should stick to the same thread. Progression of an idea is a worthy *addition* to an existing thread that you started. Creating new threads and ignoring threads in progress just risks alienating contributors that offered to help you.

ok sir and im so sorry

im going to back to the first thread i post

israillaky
Light Poster
27 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

OK, perhaps mark this as solved - just to prevent others from posting here, and carry on with the old one. :)

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

ok sir thank you

israillaky
Light Poster
27 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: