Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle date format picture ends before converting entire input string

Tags:

date

time

oracle

My table has two DATE format attributes, however, when i try to insert value it throws an error: date format picture ends before converting entire input string. Here is my attempted code:

insert into visit
values(123456, '19-JUN-13', '13-AUG-13 12:56 A.M.');

I think the problem is with 12:56 but Oracle documentation says date implies both date and time.

like image 509
Buras Avatar asked Jun 20 '13 05:06

Buras


4 Answers

Perhaps you should check NLS_DATE_FORMAT and use the date string conforming the format. Or you can use to_date function within the INSERT statement, like the following:

insert into visit
values(123456, 
       to_date('19-JUN-13', 'dd-mon-yy'),
       to_date('13-AUG-13 12:56 A.M.', 'dd-mon-yyyy hh:mi A.M.'));

Additionally, Oracle DATE stores date and time information together.

like image 123
ntalbs Avatar answered Oct 02 '22 16:10

ntalbs


you need to alter session

you can try before insert

 sql : alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'
like image 34
afeef Avatar answered Oct 01 '22 16:10

afeef


What you're trying to insert is not a date, I think, but a string. You need to use to_date() function, like this:

insert into table t1 (id, date_field) values (1, to_date('20.06.2013', 'dd.mm.yyyy'));
like image 24
Andrew Logvinov Avatar answered Sep 29 '22 16:09

Andrew Logvinov


I had this error today and discovered it was an incorrectly-formatted year...

select * from es_timeexpense where parsedate > to_date('12/3/2018', 'MM/dd/yyy')

Notice the year has only three 'y's. It should have 4.

Double-check your format.

like image 42
birwin Avatar answered Sep 29 '22 16:09

birwin