MySQL Forums
Forum List  »  General

Re: How to round a datetime field
Posted by: Saggi Malachi
Date: March 17, 2008 05:33AM

Hi,
I think an easier way to do this would be:
select from_unixtime(round(unix_timestamp('2006-10-10 14:15:01')/(60*30))*(60*30));
select from_unixtime(round(unix_timestamp('2006-10-10 14:14:59')/(60*30))*(60*30));

You can of course replace 30 with any number of minutes you'd like to round to.
replacing ROUND with FLOOR might sometimes be useful as well.

Options: ReplyQuote


Subject
Written By
Posted
December 20, 2006 09:04AM
Re: How to round a datetime field
March 17, 2008 05:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.