S
S
sflyer2016-09-16 12:49:49
Oracle
sflyer, 2016-09-16 12:49:49

Oracle 10g, ora-01843, how to set date?

I want to say right away that I'm not a professional in Oracle, but reading manuals and searching Google did not help.
Problem - lifted the new oracle 10g server, filled in the data.
When I try to interact with the data, I get an error - ora-01843 (not a valid month).
The data date looks like this: 19-DEC-07 .
I do the command:
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YY';
Then:
SELECT TO_DATE('20-DEC-07') FROM TABLE;
I get the result
ORA-01843: месяц не верен.
As a result, two questions:
1) What data format should be for this date as an example?
2) How to write information about the date format to the database so that the setting does not crash after the server is restarted?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
protven, 2016-09-16
@sflyer

Do "select sysdate from dual;" I think you have months there simply called in Russian. In general, I usually use nls_date settings to something like "DD-MM-YYYY" to avoid this. Months will be numbers.

D
Danila, 2016-09-16
@Ke1eth

1) ALTER SESSION SET NLS_DATE_FORMAT = 'MM-MON-YY';
Straight: MM-MON-YY? those. month-month-year
2) It's easier to specify the format in to_date itself
3) As far as I remember, the abbreviation depends on NLS_LANG on the client, i.e. check:

SELECT TO_DATE('20-Дек-07', 'DD-MON-YY') FROM TABLE;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question