954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Convert varchar2 format to datetime format

i want to find records between two dates IN ORCALE but the table field values is in "mm/dd/yy hh:mm::ss" and data type is varchar2
The query which i was trying was:

SELECT * FROM NEW_OUTPUT_UPLOAD_TSN
WHERE OUTPUT_UPLOAD_DATE BETWEEN TO_DATE('01/13/2008 18:45:19','MM/DD/YYYY 24HH:MI:SS')
 AND TO_DATE('01/13/2008 18:45:19','MM/DD/YYYY 24HH:MI:SS')
gargkapil2008
Newbie Poster
2 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

Try...

SELECT * FROM NEW_OUTPUT_UPLOAD_TSN
WHERE To_Date (OUTPUT_UPLOAD_DATE, 'MM/DD/YY HH24:MI:SS')
   BETWEEN TO_DATE('01/13/2008 18:45:19','MM/DD/YYYY HH24:MI:SS')
   AND TO_DATE('01/13/2008 18:45:19','MM/DD/YYYY HH24:MI:SS')

However, Your "between" dates are the same... NOT a range.
Is this correct?
Also... Your 24 comes AFTER the HH... NOT before.

For future reference, never use a VarChar2 datatype for a date.
You're just asking for problems like you're having now.

hfx642
Posting Pro
515 posts since Nov 2009
Reputation Points: 248
Solved Threads: 105
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You