A date column in a table won’t save the value after a correct date was entered

dateoracleoracle-sql-developer

I have a table with a column named Shipped Date. It is declared as a column of type DATE and retains NULL marks by default.

When I "edited" other columns in the table it worked, but when I entered in a standard date value such as '9/14/2017' into the Shipped Date column, the DBMS will let me enter it but it won't save it after I press TAB or ENTER.

I edited Shipped Date directly in the table. I also tried to enter "2017-14-09" and "September 09, 2017" into the column, but it still won't save it.

I put in the date with a format of "07-APR-9"8, and then I click the Commit button, and an error message popped up that said:

Could not save file table ORDERS.

Tools/Preferences/Database/NLS/Date Format has DD-MON-RR.

Is RR supposed to be year? If I wanted it in month-Date-Year then I suppose that it will be MON-DD-RR. Is that correct? I did put it in the format of DD-MON-RR (15-09-17) but it still does not work.

I am using Oracle SQL Developer version 17.2.0.188.

Best Answer

Community wiki answer:

There are loads of options/possibilities. See Datetime Format Models in the Database SQL Language Reference.

For example, if you have it set to DD-MON-RR, you should use 15-SEP-17.

RR lets you store 20th century dates in the 21st century using only two digits, as described in The RR Datetime Format Element:

The RR datetime format element is similar to the YY datetime format element, but it provides additional flexibility for storing date values in other centuries. The RR datetime format element lets you store 20th century dates in the 21st century by specifying only the last two digits of the year.

If you use the TO_DATE function with the YY datetime format element, then the year returned always has the same first 2 digits as the current year. If you use the RR datetime format element instead, then the century of the return value varies according to the specified two-digit year and the last two digits of the current year.

That is:

  • If the specified two-digit year is 00 to 49, then
    • If the last two digits of the current year are 00 to 49, then the returned year has the same first two digits as the current year.
    • If the last two digits of the current year are 50 to 99, then the first 2 digits of the returned year are 1 greater than the first 2 digits of the current year.
  • If the specified two-digit year is 50 to 99, then
    • If the last two digits of the current year are 00 to 49, then the first 2 digits of the returned year are 1 less than the first 2 digits of the current year.
    • If the last two digits of the current year are 50 to 99, then the returned year has the same first two digits as the current year.