这篇文章主要讲解了“Oracle怎么获取年和月”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Oracle怎么获取年和月”吧!
CREATE OR REPLACE FUNCTION comm.get_year(start_date DATE,end_date DATE)
RETURN NUMBER
IS
service_interval INTERVAL YEAR TO MONTH;
years_of_service NUMBER;
BEGIN
service_interval := (end_date - start_date) YEAR TO MONTH;
years_of_service := EXTRACT(YEAR FROM service_interval);
RETURN years_of_service ;
END;
CREATE OR REPLACE FUNCTION comm.get_month(start_date DATE,end_date DATE)
RETURN NUMBER
IS
service_interval INTERVAL YEAR TO MONTH;
months_of_service NUMBER;
BEGIN
service_interval := (end_date - start_date) YEAR TO MONTH;
months_of_service := EXTRACT(MONTH FROM service_interval);
RETURN months_of_service ;
END;
感谢各位的阅读,以上就是“Oracle怎么获取年和月”的内容了,经过本文的学习后,相信大家对Oracle怎么获取年和月这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是编程网,小编将为大家推送更多相关知识点的文章,欢迎关注!