我需要使用PROCEDURE编写SQL QUERY - 显示特定年份的DAY(dd-mon-yyyy)

时间:2016-04-20 06:52:48

标签: mysql

我需要输出as-

THE DAY ON 13-MAY-2015 IS Wednesday   
THE DAY ON 13-MAY-2016 IS Friday  
THE DAY ON 13-MAY-2017 IS Saturday  

存储过程是:

CREATE OR REPLACE
PROCEDURE display_day2(
day_disp IN VARCHAR2)
IS
l_next_year  VARCHAR2(50);
CURSOR C1
IS
SELECT TO_CHAR(TO_DATE(day_disp,'DD-MON-YYYY'),'DAY') disp_day FROM DUAL;
BEGIN
FOR R1 IN C1
LOOP

l_next_year := ADD_MONTHS (TO_DATE(day_disp,'DD-MON-YYYY'),12);
dbms_output.put_line('THE DAY ON '|| l_next_year ||' IS ' || R1.disp_day);

END LOOP;
END display_day2;

---------------
DECLARE
BEGIN
display_day2('13-MAY-2014');
END;
------------------

1 个答案:

答案 0 :(得分:0)

SELECT DATENAME(WEEKDAY,GETDATE())

应该为你提供你的目标