How to cast an interval postgresql?
I have a table where
date | interval
juin 1, 2022, 12:00 AM | 0 years 0 mons 0 days 0 hours 1 mins 58.963179 secs
juin 2, 2022, 12:00 AM | 0 years 0 mons 0 days 0 hours 2 mins 34.083955 secs
juin 3, 2022, 12:00 AM | 0 years 0 mons 0 days 0 hours 2 mins 51.152488 secs
etc...
I want to cast the interval to have a timestamp. I am in postresql
SELECT
DATE_TRUNC('day', "order_date") as date_authorised,
avg("difference") AS "avg_time"
FROM "test"
where date_trunc('day',order_date)GROUP BY DATE_TRUNC('day', "order_date")
that's my code
date + interval → timestamp
Add an interval postgresql to a date
date '2001-09-28' + interval '1 hour' → 2001-09-28 01:00:00
SELECT to_timestamp('2020-01-10 08:00', 'YYYY-MM-DD hh24:mi')::timestamp without time zone at time zone 'Asia/Calcutta' -
to_timestamp('2020-01-10 08:00', 'YYYY-MM-DD hh24:mi')::timestamp without time zone at time zone 'Etc/UTC'