Traducir el blog
Randomly overflowed dates in Excel
Analysis of Excel dates
This weekend I set out on an exercise that consisted of fill an Excel table with dates and times randomly increased. Trivial thing at first! Or not?
What was my surprise when I found a problem that I did not expect with the decimal number formats representing the date and time. Insignificant thing if you're not very meticulous! Or not?
The fundamental premise with dates in Excel is that the day is stored as an integer serial number and time is the decimal part of the day. Drawer thing! Or not?
My discovery tells me that dates stored as decimals do not always correspond to the dates displayed in date format. Thing never seen before! Or not?
Date and time format in Excel (see link here):
Displays date and time serial numbers as date values, according to the type and locale (location) that you specify. Date formats that begin with an asterisk (*) respond to changes in regional date and time settings that are specified in Control Panel. Formats without an asterisk are not affected by Control Panel settings.
What a mess I've gotten myself into! Or not?
Format and value of dates and times
In A2 cell I write the date: 03/20/2021 23:59:58
Its decimal value is displayed with 15 digits: 44275.9999768519
The integer part is the serial number representing the number of days since January 1, 1900. The integer number corresponds to the day 03/20/2021: 44275
The decimal part is the fraction of a day. The decimal value 0.9999768519 is equivalent to 23:59:58 in hh:mm:ss format, with hh:hours; mm: minutes; ss: seconds.
Decimal accuracy
Excel can display the time as a decimal number with 15 digits significant, as we're going to see by adding up the decimal part of the hours, minutes and seconds:
- 0.958333333333333 = 23/24 it's 23 hours.
- 0.0409722222222222 = 59/60/24 it's 59 minutes.
- 0.000671296296296296 = 58/60/60/24 it's 58 seconds.
The sum of these 3 decimal numbers gives:
- 0.999976851851852 = (23 + (59 + 58 / 60) / 60) / 24
- it's 23 hours, 59 minutes and 58 seconds as a decimal part of a day.
If you like numbers like me, you'll see that sum with 15 digits 0.999976851851851 being the last figure being 1 in place of a 2. This is because Excel represents 15 digits but secretly stores 17 significant digits, what the calculated sum will be:
- 0.95833333333333333000 it's 23 hours.
- 0.04097222222222222200 it's 59 minutes.
- 0.00067129629629629629 it's 58 seconds.
The sum of the previous 3 decimal places with 17 digits of precision is the decimal:
- 0.99997685185185184 which is represented as the time 23:59:58 and that is rounded to 15-digit display: 0.999976851851852
Bill Jelen, one of Excel's top gurus, known worldwide as MrExcel, wrote an excellent article warning of some of the problems derived from the internal accuracy of the Excel calculation engine. Access the following link in English to study it:
On this important issue of Excel's internal accuracy, I will return to talk below. Keep reading this article to the last one to find out more about the accuracy of dates. Case you're interested in it! Or not?
Random dates and times
In A3 cell I write the following formula and drag it down:
=A2+RAND()/100000
What I do is add a very small random value to a date and time, divided by one hundred thousand, so that the date and time increment is minimal.
In this image you can see the result obtained in the 'Random' sheet, which you can download below:
We look at the cells marked with red background color, in which we are calculated the integer part of the date. Unexpected thing! Or not?
You can verify that the day represented in column A does not match, the 03/21/2021, with day 03/20/2021 in column B, which is equivalent to the integer part of the date, equal to 44275. This problem occurs 2 times in this random execution, but can occur several more times. Undesirable thing! Or not?
Problem with inaccurate dates
When dates are randomly generated, the decimal part of a date close to one, makes the format of date numbers in Excel overflows, showing the next day, when the integer part of the serial number of the date corresponds to the previous day. Inexplicable thing! Or not?
The following image shows the decimal accuracy of various formats dates that generate overflow in the 'Dates' sheet.
In red background color are marked the dates shown for those that do not agrees on its corresponding day, i.e. date serial number which is integer part . Unforgivable thing! Or not?
Accuracy of the numerical date format
If you've read Bill Jelen's article:
you've seen that Excel's calculation engine stores and calculates decimal places more accurately (17 digits) than the one represented (15 digits). You already knew that! Or not?
With the decimals of the dates the same thing also happens. Dates can have more decimal places than the dates displayed, which creates a problem when decimal digits are close to the unit, as we can see with this example:
- 44275.9999999999 with the serial number of 5 figures 44275, represents the day 03/20/2021
- but shows the day 03/21/2021, due to internal rounding of Excel's numeric date format. Dangerous thing! Or not?
Proposed solution for overflowing dates
The solution proposed by Bill Jelen, in his article on the internal accuracy of the Excel calculation engine, can also be applied to this new problem with date format.
The problem can be solved by rounding the date down to 5 decimal places, with this formula:
=ROUNDDOWN([@Date],5) = 44275.99999
with only 10 digits of precision, 5 for the day and another 5 for the decimal part of the day, which is displayed as the correct date and time: 03/20/2021 23:59:59 Desired thing! Or not?
Overflow dates template
Download the template I've written this article with since Microsoft OneDrive, or play with the template embedded in my blog from here:
Inexplicably the 4 buttons on the bottom right of the embedded Excel have not responded for a few days, so the file cannot be downloaded with the Download button. I have filed an issue incident to the Microsoft Support and and I have commented about in the Microsoft Excel Tech Community here, but we already know that things at the palace are going slowly... Truth or not truth?
Finally the buttons respond! It's been 11 days with no response due to poor OneDrive service with the embedded workbooks into blogs or webs. The issue has lasted from January 5 to January 16, 2023. It will happen again? Surely yes!
ATTENTION: Excel Online does not allow recalculating with the F9 key. In the 'Random' sheet, you can modify the A2 cell and it will recalculate everything. Better thing! Or not?
NOTE: Microsoft Excel is designed around the IEEE 754 specification, and the IEEE 754 specification has some limitations.
The limitations of this problem and the solution to the problem can be found in the following article:
Floating-point arithmetic may give inaccurate result in Excel - Office | Microsoft Learn
I'll soon publish the randomly generated date table and see what motivated this simple exercise. Curious thing! Or not?
You can now read the blog post that inspired me when I detected the problem with overflowed dates when I was preparing a macro to randomly fill a million visits to my blog.
Post in Spanish easily translatable into more than 100 languages with the Google box at the top left of this post:
Mi lista de blogs
-
Calculadora de Premios de la Lotería de Navidad - 🔝*Select the language of this blog post in the Google box at the top left. * *Actualización 2024-12-22: *Nueva calculadora Excel para bajarse la *lis...Hace 1 día
-
CREAR APP PARA LEER CÓDIGOS QR Y GUARDAR FECHA DE ESCANEO - Hola a todos! Hace casi un mes publicaba cómo podíamos hacer una App que fuese capaz de leer los códigos de barras: CREAR APP PARA … La entrada CREAR AP...Hace 1 día
-
Calendario 2025 Excel: Imprime, Personaliza y Organiza tu Año - Calendario 2025 Excel ya puedes descargar la plantilla para imprimir gratis. En formato hoja de cálculo Excel. Escribe a hola@excelcontabilidadytic.com y...Hace 1 día
-
Sumas de potencias consecutivas - Existen fórmulas para sumar las primeras potencias de números naturales. Son populares las de la suma de potencias con los primeros exponentes. En esta c...Hace 5 días
-
FREE Calendar & Planner Excel Template for 2025 - Here is a fabulous New Year gift to you. A free 2025 Calendar Excel Template with built-in Activity planner. This is a fully dynamic and 100% customizabl...Hace 5 días
-
Secretos de Excel que ni los Expertos Dominan – PARTE 1 - Hace poco, en un Live con mi amigo Gerson Pineda, caímos en la cuenta de algo interesante: hay detalles en […] The post Secretos de Excel que ni los Expe...Hace 5 días
-
Scipy update and Linalgfuncs speed check - I have updated the Scipy code to remove repeated loading of the Numpy code, and to fix a number of other warnings from the pyxll log file. I have also upda...Hace 1 semana
-
Debra’s Excel News–December 2024 - Fix a column header problem, QAT tips, and more, in this month’s Excel news. Visit my Excel website for more tips, tutorials and videos, and check the inde...Hace 1 semana
-
5 Ways To Show All Notes in Microsoft Excel - Are you wondering how to show all notes in Excel? To unlock all the secrets of Microsoft Excel worksheet notes, keep reading! Managing notes in Excel can f...Hace 4 semanas
-
Color, Conditions, and Copilot: How to save time using conditional formatting with Copilot in Excel - Hi everyone, this is part 11 in a series of posts to show you some of the things that are possible to do with Copilot in Excel. *What is conditional f...Hace 1 mes
-
4 ejemplos de utilización de validación de datos con fórmulas - Ya sabes que la herramienta de Validación de datos es de gran utilidad para controlar y restringir la introducción de datos y así, asegurarte de…Hace 3 meses
-
Trucos de Excel: Referencias Relativas, Absolutas y Mixtas Explicadas ✨ [VIDEO] - ¡Hola a todos! Hoy hablaremos sobre un tema muy importante para quienes usan Excel: los tipos de referencia. Las referencias son fundamentales al momento d...Hace 3 meses
-
How To Predict Bearing Life With Excel - When you work in mechanical engineering, understanding the reliability and performance of bearings under various conditions is crucial. Bearings are the co...Hace 3 meses
-
-
Minutos de juego y puntos. El Espanyol, sus finales de partido y mis enfados - Pienso que el Espanyol este 2024 se está dejando muchos puntos al final de los partidos. Cuando el ... Leer más » The post Minutos de juego y puntos. El ...Hace 8 meses
-
TikTok’s search evolution - 2 in 5 Americans use TikTok as a search engine. Nearly 1 in 10 Gen Zers are more likely to rely on TikTok than Google as a search engine. More than half of...Hace 9 meses
-
MASTERCLASS Gratis – Gráfica de Gestión Proyectos en #EXCEL. - Aprende a crear un Gráfico de CURVA S, ideal para GESTIÓN DE PROYECTOS, porque te permite identificar como esta tu proyecto tanto en COSTOS como en TIEMP...Hace 10 meses
-
Demos cursos de Excel 2007, 2010, 2013, 2016, 365 - Puedes consultar las demostraciones de los siguientes capítulos de los cursos Excel. Demo cursos ExcelHace 11 meses
-
Unblocking and Enabling Macros - When Windows detects that a file has come from a computer other than the one you're using, it marks the file as coming from the web, and blocks the file....Hace 1 año
-
Office Scripts: Trabajando con Tablas - [image: Office Scripts: Trabajando con Tablas] Me he dado cuenta que últimamente solo escribo de lenguaje M (es mi pequeño vicio)... pero hay que liberar l...Hace 1 año
-
Hello world! - [image: Hello world!] Welcome to WordPress. This is your first post. Edit or delete it, then start writing!Hace 2 años
-
La importancia de saber mecanografía en 2022 - [image: Resultado de imagen de mecanografía viñeta escribiendo a máquina] Según la RAE, la mecanografía es el arte de escribir a máquina. Hace unos cuantos...Hace 2 años
-
London Excel Meetup Workbooks - The workbooks used in my presentation on “Analytical and Interactive Dashboards in Excel” at the London Excel Meetup, September 3, 2020Hace 4 años
-
Cálculo de jornada que termina al día siguiente (Power Query) y despedida - [image: Cálculo de jornada que termina al día siguiente (Power Query) y despedida] Este blog se ha ocupado de cálculos de tiempo con bastante intensidad, c...Hace 4 años
-
Agenda Perpetua Excel Calendario Perpetuo - Saludos a los ingenieros y a todos los que forman parte de nuestra comunidad de planillas Excel para ingeniería civil, ya se vienen las fiestas navideñas y...Hace 5 años
-
International Keyboard Shortcut Day 2019 - The first Wednesday of every November is International Keyboard Shortcut Day. This Wednesday, people from all over the world will become far less efficient...Hace 5 años
-
Welcome, Prashanth! - Last March, I shared that we were starting to look for a new CEO for Stack Overflow. We were looking for that rare combination of someone who… Read more "W...Hace 5 años
-
Visualize parts and whole - combine clustered column and stacked column charts - *Inga: Disa what?* *Igor: -ppeared.* by The FrankensTeam ------------------------------ Really it was 3 years ago we posted our last article? *Freddy: Th...Hace 5 años
-
Salvador Sostres, analfabeto profesional - Los nuevos tiempos traen nuevas profesiones. Internet, además, ha revolucionado el mundo del periodismo y la palabra escrita. Adaptarse o morir, ese es el ...Hace 6 años
-
Planificación de compras - Realizar una lista con los productos que necesitamos y que formarán parte de nuestra cesta de la compra nos ayuda a *encontrar la combinación de bienes p...Hace 12 años
-
-
-
-
-
-
-
-
-
2 Response to "Randomly overflowed dates in Excel"
You can follow my comment into the Microsoft Excel Tech Community here:
Embedded Excel Spreadsheets buttons do not function
Finally the buttons respond! It's been 11 days with no response due to poor OneDrive service with the embedded workbooks into blogs or webs. The issue has lasted from January 5 to January 16, 2023. It will happen again? Surely yes!
Leave A Reply
Indícame las erratas que encuentres y qué es lo que te gustaría ver en los próximos artículos.