vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| On 22 May 2007 10:08:24 -0700, jws <jsacksteder@gmail.com> wrote: > > Is there a way to round an interval to the nearest minute or do I need > to create a function for this? > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings > date_trunc('minute',interval) see http://www.postgresql.org/docs/8.2/i...DATETIME-TRUNC Peter Childs |
| ||||
| jws wrote: > Is there a way to round an interval to the nearest minute... Yes. See date_trunc function. Of course this truncates down to the specified unit. If you want to round up/down to the nearest minute I suppose you could just add '30 seconds'::interval before truncating. select now(), date_trunc('minute', now()), date_trunc('minute', now()+'30 seconds'::interval); -[ RECORD 1 ]----------------------------- now | 2007-05-22 10:25:37.706279-07 date_trunc | 2007-05-22 10:25:00-07 date_trunc | 2007-05-22 10:26:00-07 Cheers, Steve ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match |