Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: rounding to 15 seconds
"Jake" <me_at_heyjay.com> wrote in message news:<bkn3hr$i3h$1_at_bob.news.rcn.net>...
> Hi,
>
> I have a process that retrieves a stock quote, roughly, every 15 seconds.
> I'd like to round the date to every 15 seconds, so that the dates end on 0,
> 15, 30, 45 seconds.
>
Try this (note: I've used sysdate as the date): This rounds down.
select
to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') as "sysdate",
to_char(sysdate,'YYYY/MM/DD HH24:MI:') ||
to_char(trunc(to_number(to_char(sysdate,'SS'))/15)*15) as rounded
from dual
/
Results returned (edited slightly):
SYSDATE ROUNDED
------------------- --------------------- 2003/09/22 16:25:44 2003/09/22 16:25:30