I have a date column. Now my task is to create a udf. The basic purpose of this UDF is to check an year of a date. This is in ORACLE.
If year is less than 1753 assign year as 1753 and return date.
Ex:
1) select xyz_fun('1800-01-01') from a_table => Return 1800 - 01 -01
2) select xyz_fun('1600-01-01') from a_table => Return 1753 - 01 -01
3) select xyz_fun('0001-01-01') from a_table => Return 1753 - 01 -01
Return value should be Date.
I've written a UDF, but it returns warning, though no warning is shown.
create or replace function someschema.change_date(date1 in date) return date
;
begin
if( extract(year from date1) < 1753 )
then
return to_date('1753'||'-'|| to_char(date1,'MM')||'-'|| to_char(date1,'dd'),'yyyy-MM-dd');
else
return date1;
end if;
end;