How to Convert Seconds to HH:MM:SS Format in Google Sheets

In this post, get the formula to properly convert seconds to HH:MM:SS format in Google Sheets.

For example, the elapsed time is 100,000 seconds in cell C2. My formula in cell D2 will convert this elapsed time in seconds to 1 day 03:46:40.

How?

Some of you may think that by formatting cell C2 or using a TEXT function in cell D2 (given after a few paragraphs below), you can achieve the above result. It won’t work on the contrary!

For example, cell C2 contains the elapsed time in seconds (100,000) that you want to convert to hours, minutes, and seconds in HH:MM:SS time format in Google Sheets.

Select this cell (just click C2) and apply Format (menu) > Number > Duration or Format (menu) > Number > Time. Both will give you wrong results.

Even the following Text formula wont convert the total seconds to the said time format!

=text(C2,"HH:MM:SS")

Then what is the solution?

In any cell, for example, cell D2, if you divide C2 by 86,400 (60 seconds * 60 minutes * 24 hours = 86,400), then you can format that cell to the duration from the format menu.

You will get the correct duration as below.

seconds to duration - sheets

Instead of Duration, if you select Time format, then you will get 03:46:40. It skips 24 hours (day), so obviously not correct, anyway, right?

Get the correct solution, which is a formula, step-by-step below.

Convert Seconds to HH:MM:SS, but Not to Duration, in Google Sheets

If you want to convert seconds to time format like HH:MM:SS as below in Google Sheets, then please read on.

convert seconds to hh:mm:ss in Google sheets

I’ll use four simple functions as a combination. Those functions are TRUNC, MOD, TEXT, and IFS.

I’ll guide you on how to combine these functions based formulas and create seconds to HH:MM:SS converter in Google Sheets.

Refer: Google Sheets Function Guide.

First, we will apply two key formulas (TRUNC and MOD+TEXT) in cell D5 and D6. We can remove these formulas later.

Here are the steps, one by one.

Steps

Step 1: TRUNC formula in cell D5 that returns the number of days from the total seconds in cell C2.

=trunc(C2/86400)

Step 2: MOD + TEXT formula in cell D6 that returns the remaining seconds in time format.

That means the balance seconds in time format after converting the total seconds in cell C2 to days in the above step # 1.

=text(mod(C2/86400,1),"HH:MM:SS")

Step 3: In cell D2, just combine these two formulas and place the text “days” in between. Also, if you want, you can now empty the cells D5 and D6 (I suggest keep it for later use/reference).

=trunc(C2/86400)&" days "&text(mod(C2/86400,1),"HH:MM:SS")

We have created a formula that converts seconds to HH:MM:SS time format in Google Sheets.

But this combination has two visible issues! What’s that?

Assume the total elapsed seconds that we want to convert to the format day, hours, minutes, and seconds in Google Sheets is only 60 seconds. The above formula would convert 60 seconds to 0 days 00:01:00 instead of just 00:01:00.

In another scenario, if the seconds to convert are 150000, then the result would be 1 days 17:40:00 instead of 1 day 17:40:00.

That means we should clean the output someway. For that, we can use either of the IF or IFS logical functions. I’m proceeding with the IFS function.

How?

We just want to check whether the number of days underlying in the total elapsed seconds is less than or equal to zero, one, or greater than one.

The formula that returns the number of days underlying in the total elapsed seconds is the TRUNC formula in cell D5. We can use IFS to test it, i.e. <=0, =1, or >1.

=ifs(
     trunc(C2/86400)<=0,,
     trunc(C2/86400)=1,
        trunc(C2/86400)&" day",
     trunc(C2/86400)>1,
        trunc(C2/86400)&" days")&" "&text(mod(C2/86400,1),"HH:MM:SS"
)

The above is our final formula in cell D2 to convert seconds to HH:MM:SS format in Google Sheets. Please find the sample sheet below.

HH_MM_SS_Converter_Sheets

Thanks for the stay, enjoy!

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Marking Case-Sensitive Unique Values in Excel

Marking case-sensitive unique values provides several benefits compared to merely extracting them in an...

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

More like this

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.