Forum Discussion
janist29
Jan 29, 2021Copper Contributor
Excel date difference formula (Today)
Hi,
I am trying to calculate difference between today and expiry date
I tried 2 approaches:
1st- using a following formula =I3-today()
I3 is my expiry date which is written in date format 02/04/2021
2nd- using excel help =DATEDIF(TODAY(),I3,"y")
In both instances results are the same 00/01/1900
I have attached spreadsheet for your information and the formula am trying to work is on column name-days left.
- srdobraisBrass Contributor
Buen día janist29 :
Tres errores:
Primero: La función DateIF se considera para compatibilidad con Lotus. (puede generar errores)
Segundo: En dicha fórmula utilizas el parámetro "y" que se refiere a años. y como tu diferencia es menor a un año el resultado es 0 (cero).
Tercero: el formato de la columna es de fecha por lo que el resultado intenta convertirse en una fecha. y como Excel calcula las fechas a partir de 01/Jan/1900 y el resultado de la diferencia es menor que un año en la celda se muestra año 1900 etc.
Por otro lado:
NUNCA, NUNCA, NUNCA, se deben crear tablas con filas en blanco (sin datos) se ven muy bonitas pero no son eficientes. Supongo que lo has hecho para poder poner distintas formulas para una sola columna. cuando se requiere de forma temporal comparar el resultado de dos fórmulas se deben usar dos columnas. EN UNA TABLA NUNCA SE DEBEN MEZCLAR FORMULAS EN UNA COLUMNA, la tabla pierde su funcionalidad.
Cada cosa es para lo que es.
- ArifMSheikhCopper Contributor
Try this formula =INT(I3-TODAY())&" days "&TEXT(I3-TODAY(),"h"" hrs ""m"" mins """)srdobrais
Checked attached sample files, that's only 14KB for the table with data only against about ~13MB with the table with about million of empty rows.
- mathetesSilver Contributor
I want to underscore the comment by SergeiBaklan that you eliminate blank rows. Having those rows there may make the sheet look "prettier" but they really add nothing else from a functional point of view and make the file, as he points out, a lot larger.
In addition, I'd recommend to remove all empty rows in the table. In current sample keep only first 15.
When you start typing in next row by default table will be expanded automatically with adding formulas in columns where they are. With that you will significantly improve performance and usability.
As another comment, DATEDIF() is not required to calculate difference in days.
- mathetesSilver Contributor
Changed the DATEDIF function to read =DATEDIF(TODAY(),I3,"d") and the formatting of the cell to number and remove the decimal.