How do you display "13th of November, 17 days left for
month end" without hardcoding the date.

Answer Posted / prativa mishra

create or replace function return_date(r_date DATE) return VARCHAR2
is
a number;
b VARCHAR2(200);
begin
begin
select LAST_DAY(TO_DATE(r_date,'DD/MM/RRRR')) - to_date(r_date,'DD/MM/RRRR') into a FROM DUAL;
end;
begin
select to_CHAR(r_date,'DDTH')||' '||'OF'||TO_char(r_date,'MONTH')||' ,'||a||' days left for month end' into b from dual;
end;
return b;
end;

execute:- select return_date(sysdate) from dual;

20TH OFNOVEMBER ,10 days left for month end

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the two different parts of the pl/sql packages?

787


Which is faster view or stored procedure?

688


How can you maintain the integrity of your database on instances where deleting an element in a table result in the deletion of the element(s) within another table?

863


what is log shipping? : Sql dba

821


The in operator may be used if you know the exact value you want to return for at least one of the columns.

723






What is the difference between alter trigger and drop trigger statements?

795


Which sorts rows in sql?

768


Why do we use sql constraints?

852


What is the cause of mutating table error and how can we solve it?

780


What is sql exception?

705


Will truncate release space?

672


What is the difference between numeric and autonumber?

692


What are three advantages to using sql?

729


How can we debug in PL/SQL?

850


How do I start pl sql?

666