Re: Unable to convert MySQL date/time value to System.DateTime
Posted by: Jonatan Bouillon
Date: July 28, 2017 06:11PM

I finnaly understand that the new version of mysql is using tje getdatetime function instead of the GetReader().GetMySqlDateTime(ordinal).GetDateTime();

Instead of the GetReader().GetDateTime(ordinal);

The GetDateTime(ordinal) contains the _connection.Settings.ConvertZeroDateTime options that allow to convert date in format '0000-00-00' to .net DateTime.Min.

public override DateTime GetDateTime(int i)
IMySqlValue val = GetFieldValue(i, true);
MySqlDateTime dt;

if (val is MySqlDateTime)
dt = (MySqlDateTime)val;
// we need to do this because functions like date_add return string
string s = GetString(i);
dt = MySqlDateTime.Parse(s);

dt.TimezoneOffset = driver.timeZoneOffset;
if (_connection.Settings.ConvertZeroDateTime && !dt.IsValidDateTime)
return DateTime.MinValue;
return dt.GetDateTime();

Has an alternative I compile a new version of mysql with this call instead and it fixed my problem.

Options: ReplyQuote

Written By
Re: Unable to convert MySQL date/time value to System.DateTime
July 28, 2017 06:11PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.