Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Excel LEN formula returning incorrect value for a date field

In Excel:
The field length to be calculated has this value in cell C2: 01/09/2017 00:02:01

The formula used =LEN(C2)
The result returned is 15
The correct number of characters is 19

Format of cell C2 is a custom value: "yyyy"-"mm"-"dd" "hh":"mm":"ss"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When I use this in Google Sheets, the exact same steps, I get the correct value "19".

Please advise what I can correct in Excel, thank you!

>Solution :

In Excel, the LEN function counts all characters displayed in the cell, including those from the custom format code, but in Google Sheets, the LEN function only counts the underlying value, excluding formatting characters.

To have a portable result, convert result to TEXT first:

=LEN(TEXT(C2,"YYYY-MM-DD hh:mm:ss"))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading