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
How do sql databases work?
Can we join tables without foreign key?
What is an inconsistent dependency?
What are different functions in sql?
how many groups of data types? : Sql dba
Which is better varchar or nvarchar?
how would you enter characters as hex numbers? : Sql dba
what are null values? : Sql dba
What is a join query?
How do I find duplicates in the same column?
List out the acid properties and explain?
can a stored procedure call itself or recursive stored procedure? How much level sp nesting is possible? : Sql dba
What are the topics in pl sql?
What is sqlcontext?
What is the difference between sql and t sql?