Using Postgres 9.3.5
My table has duration data in the as a text field stored as minutes:seconds,
i.e 4:52 I want the value as total seconds (i.e 4 x 60) + 52 = 292
But table also contains values such as
3:34:21 (3 hours, 34 minutes and 21 seconds) 21 (21 seconds) How can I write SQL to correct calculate duration in seconds for all these cases.
Update
select (case when duration like '%:%:%' then extract(epoch from duration::time) else extract(epoch from ('00:' || duration) ::time) end )as seconds from discogs.track t1 ; So I have this but unfortunately some values are not quite valid causing it to fail
00:70:01 How do I either ignore such values or convert them (i.e 70 x 60 + 1)