I got it working, please disregard the perl related question.

-----Original Message-----
From: Viswanatha Rao [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 18, 2004 1:15 PM
To: [EMAIL PROTECTED]
Cc: 'Wesley Furgiuele'; [EMAIL PROTECTED]
Subject: RE: select rows by compare on datetime column


Thanks, it works now. I have related question.

I am calling this from perl. 
my @values= $dbh->do("SELECT start_date FROM TableSLA WHERE NOW()-
Start_Date >= 0" );

This returns the number of rows that satisfied the condition instead of
returning an array of values for start_date.

Also If I have to get two column values start_date and end_date should I
say:

(my @values, my @values2) = $dbh->do("SELECT start_date, end_date FROM
TableSLA WHERE NOW()- Start_Date >= 0" );

Now the perl syntax is getting me. Any help is appreciated.

Thanks
Vishwa

-----Original Message-----
From: Wesley Furgiuele [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 18, 2004 11:36 AM
To: Viswanatha Rao
Cc: [EMAIL PROTECTED] List
Subject: Re: select rows by compare on datetime column

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]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to