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!

Datetime conversion in pass thru query

Status
Not open for further replies.

MyNeckHurts

Programmer
Apr 5, 2002
34
US
I've written the following pass thru query to a SQL database. I need to pull data from 3 days ago. The SQL date field is a datetime field and the query is pulling way too many records. Is there a way to convert the date in the pass thru query?

SELECT a.TXN_DT as date, a.ORD_NBR as ordno, a.ORD_LIN, a.PLANT_ID as DC, a.SKU, a.TXN_QTY as Quantity, a.TXN_CD as TxCde, a.CUST_ID as Cstno, a.CUST_SFX_CD as Suffix, a.CUST_ORD_NBR as CustPO, a.COMMENT1, a.COMMENT2, a.CUST_NM as cstname, a.SHIPTO_ADDR1 as addr1, a.SHIPTO_ADDR2 as addr2, a.SHIPTO_ADDR4 as city, a.SHIPTO_STATE_CD as state, a.SHIPTO_ZIP_CD as Zip, a.CUST_CLASS_CD as Class, a.CUST_TYPE_CD as Type, b.ORD_NBR_ORG as OrgOrdNum, b.ORD_LIN_ORG as OrgPrdLin, b.RMA_RSN_CD as RMAReasonCode
FROM Returnsdly a, ASI_COPS_ORD_DETAIL b
WHERE
a.ORD_NBR = b.ORD_NBR
AND a.ORD_LIN = b.ORD_LIN
and a.txn_dt >= getdate()-3
and a.plant_id = 'SCS'
or (a.plant_id = 'SDF'
or a.plant_id = 'NOL'
or a.plant_id = 'RTNS'
or a.plant_id = 'WMDC'
or a.plant_id = 'LSPCS')
and a.prod_ctgy = 'CP'

Thanks!
 
Since it is a passthrough query, try using convert from SQL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top