Question

I have a string "Sat Nov/30/2013" I have to convert this into date with dd-MMM-yy format.

while inserting the date into table I am doing to_date('Sat Nov/30/2013','dd-MMM-yy').

But this is generating "ORA-01858: a non-numeric character was found where a numeric was expected"

Can you please help me regarding this.

Was it helpful?

Solution

DATE columns do not have any inherent format, they are stored using Oracle's own internal representation. They only have a format for display.

To insert that string into a date column you'd need to use

to_date('Sat Nov/30/2013', 'Dy Mon/DD/YYYY')

But bear in mind that this is language-sensitive, so the date has to be entered in the same language as the session. You can override that with the optional third parameter to the to_date() function.

Then to display the date you can use

to_char(<field>, 'dd-mon-rr')

MMM isn't a recognised datetime format model element, so I'm guessing you want the month abbreviation. Which is also NLS-sensitive of course.

OTHER TIPS

Try

to_date('Sat Nov/30/2013','Dy Mon/DD/YYYY')

You can use your insert query as below:

INSERT INTO DUMMYTABLE (DATE_FIELD_NAME) VALUES (to_date('Sat Nov/30/2013','Dy Mon/DD/YYYY'));

Your dummy table should have DATE_FIELD_NAME as "DATE" Datatype.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top