Convert an INTERVAL to Seconds Jim KnicelyNovember 3, 2022 In YugabyteDB’s YSQL API, the interval data type is used to store and manipulate a time period. Examples: yugabyte=# SELECT '1 Minute 30 Seconds'::INTERVAL; interval ---------- 00:01:30 (1 row) yugabyte=# SELECT '12 Years 12 Months 12 Days 12 Seconds'::INTERVAL; interval --------------------------- 13 years 12 days 00:00:12 (1 row) I’d like to know how many seconds are in the above intervals. To find those values, I can extract the EPOCH from them. yugabyte=# SELECT EXTRACT(EPOCH FROM '1 Minute 30 Seconds'::INTERVAL) total_seconds; total_seconds --------------- 90 (1 row) yugabyte=# SELECT EXTRACT(EPOCH FROM '12 Years 12 Months 12 Days 12 Seconds'::INTERVAL) total_seconds; total_seconds --------------- 411285612 (1 row) Have Fun!