jty202,
You can use DateTime.Parse or DateTime.ParseExact to parse a string into a
date. In VB.NET you can use CDate instead of DateTime.Parse.
DateTime.Parse (or CDate) is useful to convert a string to a DateTime based
on the current regional settings in Control Panel.
DateTime.ParseExact is useful to convert a string to a DateTime based on a
specific format or a specific region/culture.
Once you have a DateTime object, you can use the DateTime.Compare method to
compare them (instead of converting them to strings). In C# you can use the
overloaded comparison operators instead of DateTime.Compare.
Something like:
Dim s As String = "14-Jan-05"
Dim d1 As DateTime '= DateTime.Parse(s)
d1 = DateTime.ParseExact(s, "dd-MMM-yy", Nothing)
Dim d2 As DateTime = DateTime.Now
If DateTime.Compare(d1, d2) < 0 Then
End If
NOTE: You can use the DateTime.ToString to format a date in a specific
format
s = d1.ToString("yyyyMMdd")
For details on custom datetime formats see:
http://msdn.microsoft.com/library/de...matstrings.asp
For information on formatting in .NET in general see:
http://msdn.microsoft.com/library/de...ttingtypes.asp
Hope this helps
Jay
"jty202" <jt****@gmail.com> wrote in message
news:OG**************@TK2MSFTNGP12.phx.gbl...
I have string that contains a date in this format (14-Jan-05). I want to
store in date object if theres one and access each part of the date
(month,
year, dates, day of week).
Specifically I want to convert it in this format 20050114 because this
way,
I can compare it with another date in this format to see which is greater.
Can something show me how to do that. Thanks