SELECT avg((cast(date_part('epoch', to_timestamp(q.last_call_time::text,'yyyy-mm-dd hh24:MI:SS') - to_timestamp(q.his_create_time::text,'yyyy-mm-dd hh24:MI:SS'))/60 as numeric ))) as avgWaitDate
-- 按小时比较差值
select * from round(cast(date_part('epoch', to_timestamp(now()::text,'yyyy-mm-dd hh24:MI:SS') - to_timestamp('2022-10-08 10:10:11','yyyy-mm-dd hh24:MI:SS'))/60/60 as numeric ),1)
-- 当前日期按24小时显示
SELECT to_char(now(),'yyyy-mm-dd hh24:MI:SS')
字符串转日期带时间 使用 to_timestamp(text,'yyyy-mm-dd hh24:MI:SS')
to_date 不带时间。
日期格式中分钟 使用"MI"!