| Date functions [message #636236] |
Mon, 20 April 2015 10:36  |
 |
P1Oracle
Messages: 60 Registered: August 2014 Location: Hyderabad
|
Member |
|
|
Hi Experts,...
declare
ab varchar2(30);
begin
select to_char(to_date('01-JAN-12','dd-mon-yy'),'dd/mm/yyyy HH24:MI:SS') INTO ab from dual;
dbms_output.put_line(ab);
end;
/
above is the query which i am able to get correct output but when i am changing ab variable data type into date format(ab date) i am getting error ..please provide me a solution for this...
Thanq
|
|
|
|
|
|
| Re: Date functions [message #636239 is a reply to message #636238] |
Mon, 20 April 2015 10:43   |
Roachcoach
Messages: 1576 Registered: May 2010 Location: UK
|
Senior Member |
|
|
What error is that then?
SQL> l
1 declare
2 ab varchar2(30);
3 begin
4 select to_char(to_date('01-JAN-12','dd-mon-yy'),'dd/mm/yyyy HH24:MI:SS') INTO ab from dual;
5 dbms_output.put_line(ab);
6* end;
SQL> /
01/01/2012 00:00:00
PL/SQL procedure successfully completed.
|
|
|
|
|
|
|
|
|
|
| Re: Date functions [message #636254 is a reply to message #636251] |
Mon, 20 April 2015 12:05   |
 |
Michel Cadot
Messages: 68776 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Do you see I did not change the variable type?
So what do you think the problem could be?
Hint:
select to_char(add_months(trunc(sysdate,'YEAR'),level-1),'MON') from dual connect by level <= 12;
And, once again, use SQL*Plus.
Also, read again my first post, it contains the answer.
|
|
|
|
|
|
|
|
|
|
|
|