date column issue [message #611967] |
Thu, 10 April 2014 08:14 |
|
guddu_12
Messages: 227 Registered: April 2012 Location: UK
|
Senior Member |
|
|
Dear all,
I want to insert the date data into column from the cursor
for dt in (select to_date('31-dec-1989', 'dd-mon-yyyy') + level stdt, LEVEL lvl from dual connect by level < 10
loop
insert into table (CALENDAR_DATE) values(TO_date(dt.stdt, 'DD-MON-YYYY HH24:MI:SS'));
COMMIT;
end loop;
end;
/
But this insert the data 09-JAN-90 instead 31-dec-0090
how to get 1990 instead 0090
|
|
|
|
|
|
|
|
|
Re: date column issue [message #611976 is a reply to message #611975] |
Thu, 10 April 2014 09:03 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Assuming calendar_date is a date all that is needed is to remove the to_Date in the insert statement as Blackswan already suggested. If that doesn't work then the OP isn't running the code they say they are.
|
|
|
|
|
|
|
Re: date column issue [message #611995 is a reply to message #611967] |
Thu, 10 April 2014 12:35 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
guddu_12 wrote on Thu, 10 April 2014 09:14
for dt in (select to_date('31-dec-1989', 'dd-mon-yyyy') + level stdt, LEVEL lvl from dual connect by level < 10
loop
insert into table (CALENDAR_DATE) values(TO_date(dt.stdt, 'DD-MON-YYYY HH24:MI:SS'));
COMMIT;
end loop;
end;
/
Maybe you want to show us the code you actually executed, because this one will not for at least 2 reasons (ie. unbalanced parenthesis and no begin/end code).
|
|
|