Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Execute immediate not supporting /retaining date formats its changing it to number

VINOD SHETTIGARJul 30 2025

Hi,

I am using Oracle 19c and facing this issue. Created Following block

declare

 v\_date1 varchar2(10):='20250101';  
v\_sql VARCHAR2(1000);  

begin

v\_sql := 'create table tst\_date as select ' || TO\_DATE(v\_date1, 'yyyymmdd') || ' date1 from dual';  

execute immediate(v\_sql);  

end;

table tst_date is getting created but the value of date1 column is not getting stored as date it is getting stored as number -25. I tried execute immediate in different ways sometime directly passing the query to execute immidiate results are same only thing it is saving some other number instead of creating date column and saving date

I am failing to understand why oracle internally chaning the date value to number while creating the table even if I am using to_date ..

Can anyone guide me what should I do so that create table creates date column and date value gets stored…

Comments
Post Details
Added on Jul 30 2025
5 comments
110 views