Skip to main content
Welcome, Guest. Please login.

Login with username, password and session length
3 Guests, 0 Users

Recent

Topic: timestamp round function (Read 4867 times) previous topic - next topic

timestamp round function

Code: [Select]
CREATE FUNCTION ts_round( timestamptz, INT4 ) RETURNS TIMESTAMPTZ AS $$
    SELECT 'epoch'::timestamptz + '1 second'::INTERVAL * ( $2 * ( extract( epoch FROM $1 )::INT4 / $2 ) );
$$ LANGUAGE SQL;