Skip to content

[Python] datetime -> [duckdb] timestamptz conversion error #6466

@Leo-ich

Description

@Leo-ich

What happens?

Incorrect timezone conversion.

To Reproduce

from datetime import datetime, timezone
import duckdb

dt = datetime.now(timezone.utc).replace(microsecond=0)
print(dt)

q = "CREATE TABLE IF NOT EXISTS test (uid INT, dt TIMESTAMPTZ)"
duckdb.execute(q).commit()

q1 = "INSERT INTO test VALUES (?, ?)"
duckdb.execute(q1, (1, dt))     # BUG time zone
duckdb.execute(q1, (2, str(dt)))
duckdb.commit()

duckdb.sql("SELECT * FROM test").show()
2023-02-25 21:02:54+00:00
┌───────┬──────────────────────────┐
│  uid  │            dt            │
│ int32 │ timestamp with time zone │
├───────┼──────────────────────────┤
│     1 │ 2023-02-25 21:02:54+05   │
│     2 │ 2023-02-26 02:02:54+05   │
└───────┴──────────────────────────┘

OS:

Linux x64, Windows x64

DuckDB Version:

0.7.0

DuckDB Client:

Python

Full Name:

Leo

Affiliation:

private

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions