ToLongDateString remove the leading day (msdn.microsoft.com)
In Visual Basic 2010 using the .Net Framework 4.0, the ToLongDateString method converts the value of the current DateTime object to its equivalent long date string representation. The date value result using this method for example is: (Monday, December 19, 2011).
A normal request is to remove the day, and only show the Month, Day and Year (December 19, 2011) The best way to accomplish this, is to remove day by splitting the string.
‘Create the directory by date
Dim thedatestringtemp As String = String.Empty
Dim thedatestring As String = String.Empty
Dim thedateday As Date = Today
thedatestringtemp = RTrim(thedateday.ToLongDateString)
‘12192011 remove the day from ToLongDateString
‘Tuesday, November 29, 2011 to November 29, 2011
Dim P1Day As String = String.Empty
Dim P2MonthandDay As String = String.Empty
Dim P3Year As String = String.Empty
Dim line As String = String.Empty
Dim linearray() As String
line = RTrim(thedatestringtemp)
linearray = line.Split(“,”)
P1Day = linearray(0) ‘1
P2MonthandDay = linearray(1) ‘2
P3Year = linearray(2) ‘3
‘left trim to get rid of any leading spaces
thedatestring = LTrim(P2MonthandDay) & “,” & RTrim(P3Year)
‘end new 12192011
My Two Cents: Since the method ToLongDateString places a comma between the day, month and the year, we use the comma to split the string into 3 seperate strings. Then we simply reassemble the string, look at the final result thedatestring. Very easy!