How do you display "13th of November, 17 days left for
month end" without hardcoding the date.
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / prativa mishra
select hire_date,
to_char(hire_date,'ddth')||' '||'of'||'
'||to_char(hire_date,'month')||','||(last_day(hire_date)-
hire_date)||'days left for month end' aa
from
employees
where TO_DATE(HIRE_DATE,'DD-MON-RRRR')=&HIRE_DATE
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / 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 |
What is the difference between truncate and drop statements?
how to debugg a procedure or package using dbms_output.put_line in plsql
Where is sql database stored?
Differentiate between syntax and runtime errors.
Hello All, Could any well write a query for the following scenario. Account(table name) No Name Amount 1 ABCD 2000.00 2 DEFG -2000.00 3 GHIJ 3000.50 4 JKLM 4000.00 5 MNOP 6000.00 O/p Should be in this format No Name Credit Debit 1 ABCD 2000.00 0 2 DEFG 0 -2000.00 3 GHIJ 3000.50 4 JKLM 0 -4000.00 5 MNOP 6000.00 o could any one give appropriate query for this Thnks in Advance Suneel Reddy
When do we use triggers?
What does count (*) mean in sql?
What does sql stand for?
What is a data manipulation language?
need to split a string into separate values. eg. col1 col2 ---------- 100 - 'a,b,c' 200 - 'a,x,d,e' 300 - 'c' result: value count ------------- a - 2 b - 1 c - 2 etc.
suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we find 4th and 5th highest salary and 1 to 10 highest salary
what the meaning of sql