问题
Calculate the time between these two timestamps in PostgreSQL, create_time='2017-11-02 05:51:13' and update_time='2017-11-02 07:36:18'
and display it on HH:MM:SS Format. it should display like this 01:45:04
回答1:
You can try just subtracting the two timestamps, then using to_char to extract out the time portion:
select
SELECT to_char('2017-11-02 07:36:18'::timestamp -
'2017-11-02 05:51:10'::timestamp, 'HH:MI:SS');
Output:
to_char
01:45:08
Demo
来源:https://stackoverflow.com/questions/47074284/how-to-calculate-the-time-between-two-timestamps-postgresql