*** BUG *** in PgSqlTimeStamp

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
RichCrane
Posts: 3
Joined: Tue 04 Mar 2014 17:53

*** BUG *** in PgSqlTimeStamp

Post by RichCrane » Wed 05 Mar 2014 17:46

Here is some sample code. This datetime format is valid PostgreSql, but unfortunately the Devart PgSqlTimeStamp class throws an error.

System.FormatException: TimeStamp format not recognized

See Code and Exception below. *** This is a blocking issue for us. ***

string dateTimeToParse = "04/19/1988 12:00:00 AM";

try
{
PgSqlTimeStamp.Parse(dateTimeToParse);

}
catch (Exception ex)
{
Debug.WriteLine(ex);
LogToScreen(ex.ToString());
}


System.FormatException: TimeStamp format not recognized.
at Devart.Data.PostgreSql.PgSqlTimeStamp.Parse(String value, String format)
at Devart.Data.PostgreSql.PgSqlTimeStamp.Parse(String value)
at PB8.Peep.WFADatabaseSandBox.MainForm.button2_Click(Object sender, EventArgs e) in c:\Develop\BlueMetal\PB8\Main\PB8.Peep.WFADatabaseSandBox\MainForm.cs:line 194

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: *** BUG *** in PgSqlTimeStamp

Post by Pinturiccio » Thu 06 Mar 2014 16:38

PgSqlTimeStamp uses the same format as the PostgreSQL server. For more information, please refer to http://www.postgresql.org/docs/8.4/stat ... TIME-TABLE
However the format, produced by the ToString and Parse methods, is determined from your operating system settings. Thus, to make sure that the conversion is symmetric when using the Parse method without specifying a format you should pass the string in the same format as returned by the PgSqlTimeStamp.ToString method. You can see the format of such a string using the following code:

Code: Select all

PgSqlTimeStamp val = new PgSqlTimeStamp(1, 1, 1, 1, 1, 1);
Console.WriteLine(val.ToString());
If you want to use another format, not the default one, you can specify this format in the Parse method using format keywords, described in the above link. For your date, the format will look like the following:

Code: Select all

PgSqlTimeStamp.Parse("04/19/1988 11:00:00 PM", "MM/DD/YYYY HH:MI:SS AM");

Post Reply