Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time Query

Status
Not open for further replies.

Trevatwork

IS-IT--Management
Nov 30, 2006
309
0
0
Can someone please tell me why my Time results are not retrieving a time value greater than 3 minutes



SELECT TIMEDIFF(EndTime,StartTime) AS 'Duration',StartTime,EndTime,NumberDialed
FROM blackvox.call_detail_records c
WHERE StartTime BETWEEN '2005-07-01 08:00:00' AND '2005-07-31 23:59:59'
AND NumberDialed LIKE '91%'
AND 'Duration' >='00:03:00'

Results:
00:01:06, '2005-07-28 14:21:03', '2005-07-28 14:22:09', '914162896552'


Thanks

Trevor
 
because 'Duration' is a string

now, `Duration` is a column, using an escaped column name, but since it contains no spaces or special characters, and isn't a reserved word, you really don't need to escape it

so try AND Duration >='00:03:00'


r937.com | rudy.ca
 
Hi

Thanks, I needed to do it like this:

WHERE TIMEDIFF(EndTime,StartTime) >='00:03:00'

Thanks

Trevor
 
or You should use a HAVING clause. A WHERE clause is limiting, that is, it is used to prevent rows being selected unnecessarily. So you cannot use calculated fields in a where clause. The HAVING clause takes effect after the selection of the rows.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top