|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DateTime.ParseExact(..)I have big problem with method ParseExact from class DateTime. Here is code sample: '----------------------------------------------------------------------------------------------------------------------------------------- Module Module1 Sub Main() Console.WriteLine("Start...") Try Dim dt_ok As DateTime = New DateTime(1899, 12, 29, 0, 0, 0) Dim dt_exception As DateTime = New DateTime(1899, 12, 30, 0, 0, 1) Dim str_ok As String = dt_ok.ParseExact(dt_ok, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) Console.WriteLine("OK: " + str_ok) Dim str_exception As String = dt_exception.ParseExact(dt_exception, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) Console.WriteLine("OK: " + str_exception) Catch ex As Exception Console.WriteLine(ex.Message) End Try Console.WriteLine("Press ENTER for exit...") Console.ReadLine() End Sub End Module '----------------------------------------------------------------------------------------------------------------------------------------- For date 1899/12/29(or 31) ParseExact works fine but for date 1899/12/30 i have exception: String was not recognized as a valid DateTime. (thrown by ParseExact ) I have read about structure DateTime and i know that this time is special but i don't understand why it dosn't want to work :/ Tkank you for all aswears. regard Pawel Modrzejewski Pablo,
The datetime.parseexact converts a string to a datetime http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatetimeclassparseexacttopic2.asp You try to convert a datetime to a string For that is the overloaded DateTime.ToString very good. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemConvertClassToStringTopic21.asp It is very strange that it works with that other date. I hope this helps, Cor Show quoteHide quote "Pablo" <pawel***@gmail.com> schreef in bericht news:1155729872.474130.13910@75g2000cwc.googlegroups.com... > Hello, > > I have big problem with method ParseExact from class DateTime. > Here is code sample: > > '----------------------------------------------------------------------------------------------------------------------------------------- > Module Module1 > Sub Main() > Console.WriteLine("Start...") > Try > Dim dt_ok As DateTime = New DateTime(1899, 12, 29, 0, 0, 0) > Dim dt_exception As DateTime = New DateTime(1899, 12, 30, > 0, 0, 1) > > Dim str_ok As String = dt_ok.ParseExact(dt_ok, > "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) > Console.WriteLine("OK: " + str_ok) > > Dim str_exception As String = > dt_exception.ParseExact(dt_exception, "yyyy-MM-dd", > System.Globalization.CultureInfo.InvariantCulture) > Console.WriteLine("OK: " + str_exception) > > Catch ex As Exception > Console.WriteLine(ex.Message) > End Try > Console.WriteLine("Press ENTER for exit...") > Console.ReadLine() > End Sub > End Module > '----------------------------------------------------------------------------------------------------------------------------------------- > > For date 1899/12/29(or 31) ParseExact works fine but for date > 1899/12/30 i have exception: > String was not recognized as a valid DateTime. (thrown by ParseExact ) > > I have read about structure DateTime and i know that this time is > special but i don't understand why it dosn't want to work :/ > > Tkank you for all aswears. > > regard > Pawel Modrzejewski >
ANN: VS.NET 2003 SP1
What is the correct format for DateTime.Compare ? Memory Usange In VB.NET Capturing the second column data from a list view box. Automaticaly Clicking a Checkbox on a webbrowser control hyperlink text ISDATE() took 8 seconds to complete ? Am I doing this right? client side dataset and dataset force immediate VS05 compile? |
|||||||||||||||||||||||