NYCPHP Meetup

NYPHP.org

[nycphp-talk] rounding time values to the nearest hour

John Campbell jcampbell1 at gmail.com
Tue Apr 29 14:15:22 EDT 2008


round(seconds / 3600)
e.g.

ROUND(TIME_TO_SEC('00:39:38')/3600) ;

-John C.


On Tue, Apr 29, 2008 at 1:58 PM, Allen Shaw <ashaw at polymerdb.org> wrote:
> Hi Gang,
>
>  Anyone have a handy way to round time values to the nearest hour?
>  I've got time values stored in the database (MySQL) and often need to group
> them by the hour (e.g., times between 09:30 and 10:29 get grouped under
> 10:00).  Up to now I've been splitting on the colon and figuring it out
> based on the separate hour and minute values, but I thought there might be a
> better way...
>
>  Thanks,
>  Allen
>
>  --
>  Allen Shaw
>  slidePresenter (http://slides.sourceforge.net)
>
>  _______________________________________________
>  New York PHP Community Talk Mailing List
>  http://lists.nyphp.org/mailman/listinfo/talk
>
>  NYPHPCon 2006 Presentations Online
>  http://www.nyphpcon.com
>
>  Show Your Participation in New York PHP
>  http://www.nyphp.org/show_participation.php
>



More information about the talk mailing list