Is my Len not working??

spcalan

Well-known Member
Joined
Jun 4, 2008
Messages
1,247
I have a date 5/28/2008

I used Len() and it gives me the value of 5.

Shouldnt it be 9?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
nope, dates are stored as numbers,

Jan 1 1900 = 1
Jan 2 1900 = 2
etc..
5/28/2008 = 39596 (5 characters)...

Try

Len(Text(A1,"m/dd/yyyy")

Hope this helps...
 
Upvote 0

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

Dates are actually held as Integer numbers in Excel and that date is actually the number

39596

whose length is 5. try changing the number format of your date cells to:

0

to see what I mean.
 
Upvote 0

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
More important question is Why are you using Len on a date? What is the ultimate goal, are you trying to extract the month or day from the date??
 
Upvote 0

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,210
I have a date 5/28/2008

I used Len() and it gives me the value of 5.

Shouldnt it be 9?

5/28/2008 is actually a 5 digit number, hence the result LEN returns.

On the other hand...

=LEN(TEXT(A2,"m/d/yyyy"))

would return what you expected.
 
Upvote 0

Forum statistics

Threads
1,191,177
Messages
5,985,140
Members
439,942
Latest member
bkexcel11230

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top