Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Filter Data based on date Condition

Sudhir_MeruDec 13 2012 — edited Dec 13 2012
Hi,

Below is the query which is performing cast operation to convert string to date. Now my requirement is to filter all the dates which is from 1/1/2010 or later.

>> SELECT
>> CAST( TICKETID AS VARCHAR2(4000)) TICKETID,
CAST(CUSTOMERID AS VARCHAR2(4000)) CUSTOMERID,
CAST(CUSTOMEREMAIL AS VARCHAR2(4000)) CUSTOMEREMAIL,
CAST(CREATEDBY AS VARCHAR2(4000)) CREATEDBY,
TO_CHAR (TO_DATE ( CAST (DATECREATED AS VARCHAR2 (4000)) , 'Mon DD YYYY HH:MIAM'),'DD-MM-YYYY HH24:MI:SS') DATECREATED
FROM TICKETS
I tried with the below format, But it shows as not a valid month to filter please suggest me how to perform the filter on this cast operation of cast conversion.


>> SELECT * FROM
>> ( SELECT
CAST( TICKETID AS VARCHAR2(4000)) TICKETID,
CAST(CUSTOMERID AS VARCHAR2(4000)) CUSTOMERID,
CAST(CUSTOMEREMAIL AS VARCHAR2(4000)) CUSTOMEREMAIL,
CAST(CREATEDBY AS VARCHAR2(4000)) CREATEDBY,
TO_CHAR (TO_DATE ( CAST (DATECREATED AS VARCHAR2 (4000)) , 'Mon DD YYYY HH:MIAM'),'DD-MM-YYYY HH24:MI:SS') DATECREATED
FROM TICKETS )
WHERE
DATECREATED >= TO_DATE('01-01-2010','DD-MM-YYYY HH24:MI:SS')
Please suggest me how to put a filter on this date.

Thanks
Sudhir
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 10 2013
Added on Dec 13 2012
12 comments
1,045 views