本文介绍了通过存储过程显示日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在MySQL存储过程中有问题
I have an problem in MySQL stored procedure
表tbl_teachers
:
id dat_teacher_doj fk_int_dept_id
1 1982-01-10 1
2 1979-09-01 1
3 1981-10-13 1
在这里,我需要创建一个存储过程来找出教师的加入日期,如果是星期一,则应显示星期一,否则应显示平日"?我需要像这样的答案:
here i need to create an stored procedure to find out the joining date of teachers and if it is a Monday it should display Monday else it should display "Weekday" ?i need the answer like:
呼叫检查日期(1982-01-10)->天工作日
call check-date (1982-01-10)->dayweekday
推荐答案
借助DAYNAME
SELECT id, dat_teacher_doj,
CASE DAYNAME(dat_teacher_doj) WHEN 'Monday' THEN 'Monday' ELSE 'Weekday' END
FROM tbl_teachers
程序:这将在localhost phpmyadmin
和workbench
CREATE PROCEDURE `GetWeekDay`(IN `paramDate` DATE)
NO SQL
SELECT CASE DAYNAME(paramDate) WHEN 'Monday' THEN 'Monday' ELSE 'Weekday' END AS 'WkDy'
致电
CALL `GetWeekDay`('2015-08-03');
这篇关于通过存储过程显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!