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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering on Time field in pass-through SQL

Status
Not open for further replies.

nmair

MIS
Mar 30, 2011
22
CA
Hello all,

I know how to filter on records based on a datetime field, such as in the following query:

SELECT ORDERS.ORDER_NO, ORDERS.ORDERDATETIME
FROM
ORDERS
WHERE ORDERS.ORDERDATETIME >= {ts '2011-12-31 00:00:00'}

But, i'm unsure of the syntax when filtering records based on a time field. For example, selecting all orders where time of order greater than 9:00 AM.

Here is the following query:

SELECT ORDERS.ORDER_NO, ORDERS.ORDERDATETIME, TIME(ORDERS.ORDERDATETIME) AS GETTIME
FROM
ORDERS
WHERE TIME(ORDERS.ORDERDATETIME) > 9:00 am

Not sure what the correct syntax would be. Any help would be greatly appreciated.

Cheers,

Neill
 
Not sure what the correct syntax would be
The syntax of the remote SQL engine.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 


hi,
Code:
SELECT ORDERS.ORDER_NO, ORDERS.ORDERDATETIME, format(ORDERS.ORDERDATETIME, 'hh:mm') AS GETTIME
FROM
ORDERS
WHERE format(ORDERS.ORDERDATETIME, 'hh:mm') > '09:00'

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip, we're talking about a pass-through query.
 


Ahhhh, yes. Need to know the Db type

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
The DB is an SQL Server 2008, I believe.
 
Is there anyway to tell for certain what kinda of a DB it is without having to contact the DBA?
 
I'd look at the connection string.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top