Search code examples
regexgoogle-sheetstimegoogle-sheets-formulanumber-formatting

Google Sheet - convert Hours & minute to seconds


Need to convert Hours & minutes to seconds.

Ex : 5h 30m -> 19800
3h 15m -> 11700

Tried to use Formatting options & the SECOND() function. But it's not working.


Solution

  • if you have 5:30 you can do this:

    =TEXT(A7, "[ss]")*1
    

    enter image description here

    if you have no idea use:

    =INDEX(IFERROR(1/(1/TEXT(REGEXREPLACE(A7:A10&"", 
     "(\d+)h ?(\d+)m", "$1:$2")*1, "[ss]"))))
    

    enter image description here