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
How can get second highest salary in sql?
Write the command to remove all players named sachin from the players table.
what is a database transaction? : Sql dba
How does a trigger work?
Can we use rowid as primary key?
How do I turn a list into a table?
Why are cursors used?
what is myisam? : Sql dba
Which join condition can be specified using on clause?
How to place comments in pl/sql?
How can you view the errors encountered in a trigger?
What are the set operators in sql?
Can we use view in stored procedure?
Which query operators in sql is used for pattern matching?
Can function return multiple values in sql?