Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: how to trunc date column to half an hour
Mark Bobak posted an example a while back for just this situation:
VARIABLE nearest_min NUMBER;
EXEC :nearest_min := 30
SELECT sysdate
, TRUNC(sysdate,'HH') + (TRUNC((sysdate - TRUNC(sysdate,'HH')) * 24 / (:nearest_min/60)) + 1) / (60 / :nearest_min) / 24FROM dual;
SYSDATE TRUNC(SYSDATE,'HH'
------------------ ------------------
It's been taking up to an hour for me to get list messages, so apologies if someone has already given you this answer.
SELECT CASE WHEN to_number(to_char(sysdate,'MI')) < 30 THEN trunc(sysdate,'HH') ELSE trunc(sysdate,'HH') + 30/(60*24) END as half_hour from dual;
You could also create a function with the same logic and use it like the trunc command.
On 3/6/07 12:16 PM, Derya Oktay wrote:
Hi All,
Is there a way of displaying date columns, truncated to half an hours.
For example: select trunc(sysdate,'HH') from dual;
Regards,
Derya.
FYI. We are usig this sort of functions in group by expressions.
PS. Ghassan thank you for your answer regarding local/global index es in partitions.
If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please resend this communication to the sender and delete the original message or any copy of it from your computer system.
Thank you.
-- http://www.freelists.org/webpage/oracle-lReceived on Tue Mar 06 2007 - 16:44:29 CST
![]() |
![]() |