VB.NET: Extract day, month or year from the Listbox

toytoy

Well-known member
Joined
Jul 16, 2004
Messages
46
Programming Experience
1-3
Say i have these dates:

12-2-05......can
12-12-05....can
12-13-05....cannot
12-22-05....cannot

Refer to the above dates, why the below XML tag could not work well with days above "12"... when i send to server..
I could only send 1,2,3,4,5,....up to 12 only.
VB.NET:
"<" & "Date" & " " & "day=" & """" & Convert.ToDateTime(lst.SelectedItem.ToString).Date.Day & """" & " " & "month=" & """" & Convert.ToDateTime(lst.SelectedItem.ToString).Date.Month & """" & " " & "year=" & """" & Convert.ToDateTime(lst.SelectedItem.ToString).Date.Year & """" & " >" & _
</" & "Date" & ">" & _
The error message is:
VB.NET:
Additional information: String was not recognized as a valid DateTime.
Does anyone have better solution to solve it....

Thanks
 

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
Random guess but it might have something to do with the date format. I.e. in the UK the dat is displayed as dd/mm/yy whereas in america it is mm/dd/yy
 
Joined
Jan 3, 2005
Messages
10
Location
KY, USA
Programming Experience
1-3
Date, Months and Years

levyuk said:
Random guess but it might have something to do with thedate format. I.e. in the UK the dat is displayed as dd/mm/yy whereas inamerica it is mm/dd/yy

So what do you have to do to fix this??? (can't you tell I'm a newbie)Is their a place in the program to tell what country you live in??
 

toytoy

Well-known member
Joined
Jul 16, 2004
Messages
46
Programming Experience
1-3
Say i have these XML tag
VB.NET:
<book published="New York">
	<date day="12" month="1" year="2005" />	
</book>
How do i exactly format the date since i am getting three different attributes (day, month and year) from the server......

Say i want the format to be "DD/MM/YYYY"...

I want the format date to be displayed in the listbox...

Does anyone have any idea to combined all three attributes and format instead of format directly the date as a whole....

Thanks
 
Top Bottom