For example:
Dim testdate As String = "29/10/2010"
testdate = Convert.ToDateTime(testdate.ToString)
Response.Write(testdate)
expecting "29/10/2010 00:00:00" what I get is "29/10/2010"
For example:
Dim testdate As String = "29/10/2010"
testdate = Convert.ToDateTime(testdate.ToString)
Response.Write(testdate)
expecting "29/10/2010 00:00:00" what I get is "29/10/2010"
You have to assign the result of Convert.ToDateTime to a DateTime object, not to the string.
Dim testdate As String = "29/10/2010"
Dim date As DateTime = Convert.ToDateTime(testdate)
Response.Write(date)
This will print the clock as well as the date in the default format for your machine.
As clearly documented here, no, this is not the designed behaviour.
'05/01/1996' converts to 5/1/1996 12:00:00 AM.
'Tue Apr 28, 2009' converts to 4/28/2009 12:00:00 AM.
It's possible that this article might provide insight.
The big problem is, as mentioned in other posts, you are implicitly assigning the DateTime result of the Convert operation to a string variable. This wouldn't even pass the compilier in C#, so your into the realm of how VB operates on these implicit assignments and you probably don't want to be there because if some part of the language specification changes in a new Framework version and you try to migrate your code, you could potentially have a nasty bug to try to find (maybe not as important here, but in other cases, yes). Best move would be to rewrite the code block to have the Convert operation assign to a DateTime object, but simplier solution would be to throw a .ToString() at the end of the Convert.ToDateTime(testdate) line (i.e. testdate = Convert.DateTime(testdate).ToString() which will leave testdate with the date and the timestamp formatted to the current culture (as you are now performing an explicit conversion between the DateTime and the destination String).