Closed DanCory closed 9 months ago
Similar to my previous bug:
using DuckDB.NET.Data; using DuckDB.NET; using DuckDBConnection duckDBConnection = new("Data Source=test.db"); duckDBConnection.Open(); DuckDbCommand command = duckDBConnection.CreateCommand(); command.CommandText = "DROP TABLE IF EXISTS intdate;"; command.ExecuteNonQuery(); command.CommandText = "CREATE TABLE intdate(foo INTEGER, bar DATE);"; command.ExecuteNonQuery(); command.CommandText = "INSERT INTO intdate VALUES (3, date '2001-02-03'), (5, date '2004-05-06'), (7, date '2007-08-09');"; command.ExecuteNonQuery(); command.CommandText = "SELECT bar FROM intdate"; DuckDBDataReader reader = command.ExecuteReader(); while (reader.Read()) { for (int c = 0; c < reader.FieldCount; c++) { Console.Write(reader.GetDateTime(c)); } Console.WriteLine(); } reader.Close();
returns
9/16/1971 1:34:29 PM
then throws an exception on the next record
should return
2/3/2001 5/6/2004 8/9/2007
Replacing reader.GetDateTime(c) with ((DuckDBDateOnly)reader.GetValue(c)).ToDateTime() works.
reader.GetDateTime(c)
((DuckDBDateOnly)reader.GetValue(c)).ToDateTime()
Fixed in 23a444e123ad52d98825786d71f97dca5b2d4c0a
The fix is now live in 0.9.1 release
Similar to my previous bug:
returns
then throws an exception on the next record
should return
Replacing
reader.GetDateTime(c)
with((DuckDBDateOnly)reader.GetValue(c)).ToDateTime()
works.