endtime 是 timestamp
select to_char(endtime, 'YYYY-MM-DD') as d , count(objectid)
FROM sde.polygon where endtime>='2004-09-01 00:00:00' and endtime <='2004-10-01 23:59:59' group by d
endtime 是 字符串时
select to_char(to_timestamp(endtime::bigint), 'YYYY-MM-DD') as d , count(objectid)
FROM sde.polygon where endtime>='2004-09-01 00:00:00' and endtime <='2004-10-01 23:59:59' group by d