I was wondering if there is a way to find the 'median' date in PostgreSQL. The goal is to obtain, according to the median, the date that is in the middle of all the dates.
I tried following modified median function:
select
percentile_cont(0.5) within group (order by date)
from cte
By trying to do so I get the following error message:
SQL Error [42883]: ERROR: function percentile_cont(numeric, timestamp without time zone) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 12
As dates are not supported, I was wondering if there is another way to calculate the median value of a date.
Thank you for any inputs!