How I can round to nearest X minutes?
Here\'s my attempt:
DECLARE _stamp ALIAS FOR $1; -- timestamp _nearest ALIAS FOR $2; -- minutes (integer)
Use the function date_trunc('src', timestamp [value]).
date_trunc('src', timestamp [value])
See the documentation: http://www.postgresql.org/docs/9.1/static/functions-datetime.html