DROP FUNCTION partial_date_from_timestamp(TIMESTAMP WITHOUT TIME ZONE);
CREATE OR REPLACE FUNCTION partial_date_from_timestamp(TIMESTAMP WITHOUT TIME ZONE) RETURNS INTEGER AS $$
  SELECT cast(replace(substr(cast($1 as text),1,10),'-','') as int);
$$ LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT;


