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

Date in varchar2 format

Status
Not open for further replies.

jcs1953

IS-IT--Management
Nov 28, 2007
53
US
I'm using this query:
SELECT REQ_PANELS.RUN_DATE, RESULTS.RESULT_NUMERIC, TESTS.TEST_NAME
FROM REQ_PANELS, REQUISITIONS, RESULTS, TESTS
WHERE REQUISITIONS.ACC_ID = REQ_PANELS.ACC_ID
AND REQ_PANELS.RP_ID = RESULTS.RP_ID
AND RESULTS.TEST_ID = TESTS.TEST_ID
AND (REQUISITIONS.PAT_ID = 'xxxxx.x')
AND (TESTS.TEST_NAME = 'GLUC')
ORDER BY REQ_PANELS.RUN_DATE

This runs fine but the Run_Date returned is 4/2/2009 12:48:17 PM. The data type for this column is varchar2(30). I need the data returned to be just mm/dd/yyyyy. TO_CHAR doesn't work as it's already CHAR. What's the best way to format this?
 
I get ORA-01830:date format picture ends before converting entire input string
 
Figured it out.
to_char(to_date(REQ_PANELS.RUN_DATE, 'MM/DD/YYYY HH:mi:SS:pM'),'mm/dd/yyyy') As Run_date
 
I would very, very strongly advise you to endeavour to get the datatype of that column changed to a date. There is never a good reason to have a date stored as text in a database such as Oracle.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top