一、不足半小时不参与计算,抹去多余分钟数:
SELECT CASE
WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'mi')) = 30
THEN TRUNC (SYSDATE, 'mi')
ELSE TRUNC (SYSDATE, 'hh24') + DECODE (SIGN (TO_NUMBER (TO_CHAR (SYSDATE, 'mi')) - 30), 1, 1 / 48, 0)
END Time
FROM DUAL;
二、不足半小时按照半小时计算:
SELECT CASE
WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'mi')) = 0
THEN TRUNC (SYSDATE, 'mi')
ELSE TRUNC (SYSDATE, 'hh24') + DECODE (SIGN (TO_NUMBER (TO_CHAR (SYSDATE, 'mi')) - 30), 1, 1 / 24, 1 / 48)
END Time
FROM DUAL;
oracle函数trunc()的具体用法参见:http://blog.csdn.net/qq_34598424/article/details/108004339