Postgresql To Find Midpoint Between Two Timestamps
I'm converting something from SQL Server to PostgreSQL. There's a table with a calculated field between a BeginTime and an EndTime called MidTime. The times are offsets from the be
Solution 1:
Just subtract one from the other divide it by two and add it to begintime:
begintime + (endtime - begintime)/2
It is correct that you can't divide a time value. But the result of endtime - begintime is not a time but an interval. And you can divide an interval by 2.
The above expression works with time, timestamp or interval columns.
Post a Comment for "Postgresql To Find Midpoint Between Two Timestamps"