Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Dealing with Large Numbers of Seconds.

Dealing with Large Numbers of Seconds

Written by Allen Wyatt (last updated June 1, 2019)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


2

Piers has a report which runs and once it is complete, he logs the start time and duration, in seconds. If A1 is the start time and B1 is the number of seconds, Piers uses the following formula to determine the ending time:

=A1+TIME(0,0,B1)

The formula works fine, unless report execution took over 32,767 seconds, which often happens. Piers wonders what formula he can use to get past this apparent Excel limitation.

First, it is important to understand that what you have discovered is, indeed, a limitation of Excel. Or, more precisely, a limitation of the TIME function. The three parameters you use in the function (representing hours, minutes, and seconds) must be integer values. That is "programming speak" for the fact that each value must be in the range of 0 to 32767. Outside that range, and you get an error.

One solution is to simply make sure that you don't use a value that is outside of this range. I like this recasting of the formula, still using the TIME function:

=A1+TIME(INT(B1/3600),0,MOD(B1,3600))

Whereas the limit in your original formula meant that you could not have a report run for much more than 9 hours (32767 seconds), this revised formula will handle durations of nearly 4 years. (If you have reports that are taking more than 4 years to run, something is probably wrong!)

Of course, you could bypass using the TIME function altogether and simply come up with your own formula to add the seconds to the value in A1. This is easier than it may seem; all you need to do is remember that time values are stored, within Excel, as fractions of a day. Since there are 86,400 seconds in each day (60 seconds * 60 minutes * 24 hours), you could use this formula:

=A1+B1/86400

Just make sure that the cell containing the formula is formatted to display times, and you'll have no problem. (Just format the cell the same way that cell A1 is formatted; you can use the Format Painter to do this.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9421) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Dealing with Large Numbers of Seconds.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Updating Multiple PivotTables at Once

PivotTables are a great way to process huge amounts of data and make sense of that data. If you have a number of ...

Discover More

Diagonal Borders in a Conditional Format

Conditional formatting is a great tool for changing how your data looks based on the data itself. Excel won't allow you ...

Discover More

AutoFill Won't Work as Expected

AutoFill is a great tool for filling cells with data. What do you do when it doesn't work like you expect, however? ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Checking for Time Input

Need to know if a cell contains a time value? Excel doesn't contain an intrinsic worksheet function to answer the ...

Discover More

Automatically Entering a Data Entry Time

Excel worksheets can be used to keep track of all sorts of information. You may want to use it, for instance, to track ...

Discover More

Adjusting Times for Time Zones

Collect a series of times in a worksheet, and you might need to adjust those times for various time zones. This involves ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine minus 5?

2019-08-15 16:03:23

Saved by Tips

This saved my life on a project!!! Thank you!!!


2019-06-01 10:52:21

Ian Norman

This is great for times that can be expressed as integers in the range -32768 to 32676, but there are many circumstances where the time-value has to be expressed as a real number, e.g. seconds-past-midnight with a resolution of microseconds or even smaller. The problem that then arises is that it's easy to exceed even the range of real numbers, which - certainly in the past, e.g. with Excel 2007 and earlier - was limited to 56 bits. I handled this by importing very large numbers as text, and then manipulating the text, e.g. by first extracting the seconds-component into one cell, and then the residue into another. It was clunky, but I +was+ able to get to nanosecond-level resolution, which was just barely acceptable for scientific measurements such as the state-time changes of electronic components.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.