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

Answer Posted / bijaylaxmi

create or replace function cal_date(i_date DATE) return VARCHAR2
is
x number;
y VARCHAR2(200);
begin
begin
select LAST_DAY(TO_DATE(i_date,'DD/MM/yyyy')) - to_date(i_date,'DD/MM/yyyy') into x FROM DUAL;
end;
begin
select to_CHAR(i_date,'DDTH')||' '||'OF'||TO_char(i_date,'MONTH')||' ,'||x||' days left for month end' into y from dual;
end;
return y;
end;
>select cal_date('13-NOV-12') from dual;
o/p:-13th of November, 17 days left for
month end".

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we use sql constraints? Which constraints we can use while creating database in sql?

723


Explain alias in sql?

765


What is query syntax?

715


What is normalization in a database?

848


What does trigger mean in slang?

733






What is a procedure in pl sql?

777


what is a relationship and what are they? : Sql dba

746


How does sql*loader handles newline characters in a record? : aql loader

763


What is the purpose of cursors in pl/sql?

798


How to return multiple rows from the stored procedure?

714


What is bitemporal narrowing?

1001


how can we destroy the session, how can we unset the variable of a session? : Sql dba

729


How many databases can sql express handle?

729


What is the best sql course?

720


What is union and union all keyword in sql and what are their differences?

803