Skip to main content
Welcome, Guest. Please login.

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

Recent

Topic: timestamp round function (Read 4800 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;