Home > database >  how to insert date values in dbms?
how to insert date values in dbms?

Time:01-26

I am using oracle dbms and created a table. One of the attributes of the table is of type date. Even after entering in YYYY-MM-DD format it still shows error ORA-01843.

This is my query

insert into reserves values(120,001,'2012-01-11');

This is the error

ORA-01843: not a valid month ORA-06512: at "SYS.DBMS_SQL", line 1721

insert into reserves values(120,001,'2012-01-11');

I tried inserting month names and also rearranging the date, still no success.
I am trying to insert this set of values

CodePudding user response:

You better tell the DB the format of the date string, like this

insert into reserves values(120,001,to_date('2012-01-11','yyyy-mm-dd');

You can also set the NLS_DATE_FORMAT like this

alter session set nls_date_format='yyyy-mm-dd';

(or whatever format you like) and then use the syntax you show in the question

CodePudding user response:


insert into reserves values(120,001,DATE'2023-01-25');

  • Related