Avatar of Star79
Star79Flag for United States of America

asked on 

Oracle Date

Hello,
I have the below query:
select distinct
	po.c_order_id 						    as source_pohdr_id,	
    'WYOMING'                               as source_system,
	v.vendor_code							as vendor_code,
	v.name									as VENDOR_NAME,
    trim(po.em_sc_program_code)             as PROGRAM_CODE,
	PGM.DESCRIPTION 						AS PROGRAM_NAME,
	substr(ltrim(po.documentno),1,12)  		as PO_DOCUMENTNO,
	cast(po.totallines	as NUMBER(18,0))	as totallines,
	po.grandtotal							as grandtotal,
	po.salesrep_id                          as source_person_id,
	PER.NAME 								AS BUYER_NAME,
    'WYOMING'                               as source_system,
	PO.DATEPRINTED 					as PRINTED_DATE,
	PO.CREATED 						AS CREATED_DATE
, POC.ORDER_TYPE 
, POC.AGREEMENT_INDICATOR 
, POC.SOURCE_JUSTIFICATION  
, POC.PRICE_ANALYSIS
, POC.CONTRACT_PROVISIONS 
, POC.GOVERNMENT_PROPERTY  
, POC.SUBCONTRACTING_PLAN  
, POC.PRIOR_CONSENT_REQUIREMENTS  
, POC.AUDIT_STATUS_SYMBOL  
, POC.PO_SUBCONTRACT_CLOSEOUT 
from c_order po
  left join sc_vendor v on ( po.c_bpartner_id = v.c_bpartner_id )
	LEFT join SC_CUSTOMER SF on PO.ad_org_id = SF.ad_org_id and SF.FRONT_END = 'STORES' 
	LEFT join SC_CUSTOMER C ON C.C_BPARTNER_ID = PO.C_BPARTNER_ID
	LEFT JOIN SC_PO_CLASSIFICATION POC ON po.C_ORDER_ID = POC.C_ORDER_ID
	LEFT JOIN sc_program PGM   ON TRIM(po.em_sc_program_code) = PGM.PROGRAM_CODE
	LEFT JOIN SC_PERSON PER ON PO.SALESREP_ID = PER.SC_PERSON_ID
WHERE 
po.issotrx = 'N' and PO.GRANDTOTAL>=3000
  	--and to_char(po.dateprinted,'MM-DD-YYYY')  between '01-31-2003' and  '07-03-2003'  
    AND  to_char(po.dateprinted,'MM-DD-YYYY')>= '01-02-2003' and to_char(po.dateprinted,'MM-DD-YYYY') <= '01-31-2003'       
    AND trim(po.em_sc_program_code) not in('XXX','U495','U181','A607')

Open in new window

The above code should pull rows which have printeddate in 1/31/2003 to 7/3/2003.But for some reason its pulling from all the date ranges years available in that table.Not sure how to handle dates in oracle where clause.
The table has date data like '06-FEB-08' and the user will pass parameter like mm-dd-yyyy format.
Please help.
Oracle Database

Avatar of undefined
Last Comment
slightwv (䄆 Netminder)
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Oracle Database
Oracle Database

Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.

81K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo