Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimeOffset DuckDBParameter #244

Open
brasio opened this issue Jan 15, 2025 · 1 comment
Open

DateTimeOffset DuckDBParameter #244

brasio opened this issue Jan 15, 2025 · 1 comment

Comments

@brasio
Copy link

brasio commented Jan 15, 2025

I get in following code this error: "Unable to bind value of type DateTimeOffset.'"

using (var connection = new DuckDBConnection("DataSource=mydb.duckdb"))
{
    connection.Open();
    // Define the DateTime and offset you want to store
    DateTime dateTimeValue = new DateTime(2025, 1, 1, 12, 30, 45);
    TimeSpan offset = TimeSpan.FromHours(-5);
    DateTimeOffset dateTimeOffsetValue = new DateTimeOffset(dateTimeValue, offset);
    string sql = "INSERT INTO mytable VALUES (?)";
    using (var command = new DuckDBCommand())
    {
        command.Connection = connection;
        command.CommandText = "CREATE TABLE IF NOT EXISTS mytable (COLUMN_TIMESTAMP_TZ TIMESTAMP WITH TIME ZONE)";
        command.ExecuteNonQuery();
        command.CommandText = sql;
        DuckDBParameter parameter = new DuckDBParameter(System.Data.DbType.DateTimeOffset, dateTimeOffsetValue);
        command.Parameters.Add(parameter);
        command.ExecuteNonQuery();
    }
    connection.Close();

Are DateTimeOffset parameters supported?
Thanks

@Giorgi
Copy link
Owner

Giorgi commented Jan 15, 2025

Not in the currently published version but should be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants