Weird value returned when using Len(Now.Month)

Ste T

New member
Joined
Jan 30, 2009
Messages
2
Programming Experience
Beginner
Hi

I've got a bit of a weird problem that I don't really understand. I need to check the current date and month to see if they are only 1 character long (1 - 9 - January to September) and if so I need to insert a 0 before the value in a string.

Now the code I have been using is Len(Now.Month) which for some reason is returning 4 even though the current Month is February (thought this would return 1).

I I use Len(Now.Month.ToString) it comes through as 1, which is what I want.

Does anyone have any idea why this is happening? The code has been in place for a while and only just started having this problem, which seems a little strange.

Thanks

Steve
 
Cant tell you why you have suddenly started seeing the problem, but there's a much simpler way :)

VB.NET:
MessageBox.Show(String.Format("{0:00}", Date.Now.Month))
 
Back
Top