Thomas Lockhart <lockhart@fourpalms.org> writes:
> thomas=# create or replace function date_part(text,int4)
> thomas-# returns float8 as
> thomas-# 'select date_part($1, timestamp without time zone \'epoch\'
> thomas-# + (interval '1 sec' * $2));' language 'sql';
Or just
regression=# create or replace function date_part(text,int4)
regression-# returns float8 as
regression-# 'select date_part($1, $2::abstime::timestamp)'
regression-# language sql;
Thomas, of course, would really like to get rid of type abstime,
but it's so dang useful (for exactly this reason) that I don't
expect it to disappear until Unixen move away from 4-byte time_t.
regards, tom lane