我编写了这个函数来获取某个日期的分钟数,但我无法获取两个日期之间的分钟数,如何获取?
I wrote this function to get minutes from a date, but I cannot get minutes between two dates, How to get that ?
FUNCTION get_minute(p_date DATE)
RETURN NUMBER
IS
BEGIN
IF p_date IS NOT NULL THEN
return EXTRACT(MINUTE FROM TO_TIMESTAMP(to_char(p_date,'DD-MON-YYYY HH:MI:SS'),'DD-MON-YYYY HH24:MI:SS'));
ELSE
RETURN 0;
END IF;
END get_minute;
当你在 Oracle 中减去两个日期时,你会得到两个值之间的天数.所以你只需要在几分钟内乘以得到结果:
When you subtract two dates in Oracle, you get the number of days between the two values. So you just have to multiply to get the result in minutes instead:
SELECT (date2 - date1) * 24 * 60 AS minutesBetween
FROM ...
这篇关于Oracle:如何减去两个日期并获得结果的分钟数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!