I have a result using SQL inside a function
select a[2] as hour, a[3] minutes from ( select regexp_split_to_array('for 7h 18m', ' ') ) as dt(a);
and i got result as
hour minutes
7h 18m
I want to get
minutes
438
One option here is to remove the h from the hours string, multiply by 60 to get minutes, then add this quantity to the minutes field, with the m removed. Try this query:
select regexp_replace(a[2], '[h\s]', '')::integer * 60 +
regexp_replace(a[3], '[m\s]', '')::integer as minutes
from
(
select regexp_split_to_array('for 7h 18m', ' ')
) as dt(a);