Yeah I wasn't checking MSDN I was just fooling around.
The weird part is that if you don't use DateTime and you just use Date it still behaves the same way....
Checking MSDN
Ok that is just silly.
The DateTime class has a "Date" property that returns a new DateTime object with only the date set (but the time is left as default which is midnight).
I know that there is a Date in .NET, I've used it before but it seems that the MSDN only has information on Java's Date class (I was using it yesterday when I was playing around...and for some reason the Date Objects also had Time...hmm I remember something about this from school...but it was a long time ago and I obviously haven't been using Date/DateTime Objects since then so it's all a little fuzzy) .
The weird behaviour of the Date/DateTime Object has been explained now thanks to MSDN.
It's working as expected...
-
Dim str As New StringBuilder
-
Dim x As String = "11/6/2009 14:00"
-
Dim dx As Date
-
Date.TryParse(x, dx)
-
str.Append("dx:")
-
str.Append(Environment.NewLine)
-
str.Append(dx.Date.ToString) ' <-- returns a new DateTime Object with just the date set
-
str.Append(Environment.NewLine)
-
str.Append(dx.ToString) ' <--uses the current DateTime Object
-
str.Append(Environment.NewLine)
-
str.Append(dx.ToString("M/d/yyyy h:mm tt"))
-
str.Append(Environment.NewLine)
-
str.Append(dx.Hour.ToString.PadLeft(2, "0"))
-
str.Append(":")
-
str.Append(dx.Minute.ToString.PadLeft(2, "0"))
-
str.Append(":")
-
str.Append(dx.Second.ToString.PadLeft(2, "0"))
-
str.Append(Environment.NewLine)
-
str.Append(Environment.NewLine)
-Frinny <-- feeling like a newbie all over again