Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: rounding to 15 seconds
Thanks Patrick
Jake
"Patrick Connors" <pmc_at_finger-rock.com> wrote in message
news:c0f4d322.0309221527.3c465454_at_posting.google.com...
> "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
> 2003/09/22 16:25:46 2003/09/22 16:25:45
> 2003/09/22 16:26:27 2003/09/22 16:26:15
Received on Mon Sep 22 2003 - 21:52:53 CDT