Vishwa:
Sorry -- I used a specific time value as an example, but since you were asking about current time, you would use CURTIME():
SELECT columns FROM table WHERE DATE_FORMAT( start_time, '%H:%i:%s' ) >= CURTIME() AND DATE_FORMAT( end_time, '%H:%i:%s' ) <= CURTIME();
Wes
On Aug 18, 2004, at 12:24 PM, Wesley Furgiuele wrote:
Does the date matter, or only the time?
If date matters (you want to find all records between 2004-06-01 10:00:00 AND 2004-06-03 18:00:00):
SELECT columns FROM table WHERE start_time >= '2004-06-01 10:00:00' AND end_time <= '2004-06-03 18:00:00'
If only time matters( you want to find all records between 10:00:00 AND 18:00:00 on any day):
--> If you're using version 4.1.1 or greater:
SELECT columns FROM table WHERE TIME( start_time ) >= '10:00:00' AND TIME( end_time ) >= '18:00:00'
--> Otherwise:
SELECT columns FROM table WHERE DATE_FORMAT( start_time, '%H:%i:%s' ) >= '10:00:00' AND DATE_FORMAT( end_time, '%H:%i:%s' ) <= '18:00:00'
Wes
On Aug 18, 2004, at 11:39 AM, Viswanatha Rao wrote:
I have two columns in a table: start_time and end_time. Both are of types DATETIME When I select rows from table, I want to select only those rows where the current time falls between start_time and end_time
Can someone help with the SELECT syntax for this?
Best Regards Vishwa Rao
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]