Skip to content

bug: duckdb offset_by('1d') adds 24 hours, rather than 1 calendar day #3465

@MarcoGorelli

Description

@MarcoGorelli

in duckdb, adding an interval of 1 day is different to using date_add with '1 day':

print(duckdb.sql("""
SET timezone = 'Europe/Amsterdam';
select a,
       date_add('24 hours', a) as b,
       a + '1 day'::INTERVAL as c
from values (CAST('2025-10-26' AS TIMESTAMPTZ),) df(a)
"""))
┌──────────────────────────┬──────────────────────────┬──────────────────────────┐
│            a             │            b             │            c             │
│ timestamp with time zone │ timestamp with time zone │ timestamp with time zone │
├──────────────────────────┼──────────────────────────┼──────────────────────────┤
│ 2025-10-26 00:00:00+02   │ 2025-10-26 23:00:00+01   │ 2025-10-27 00:00:00+01   │
└──────────────────────────┴──────────────────────────┴──────────────────────────┘

In Narwhals, we're using date_add:

https://github.com/narwhals-dev/narwhals/blob/092c1c30c43632f2591c3c1955da81eb726e6a70/narwhals/_duckdb/expr_dt.py#L104-L105]

we should probably be summing an interval instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: incorrect resultSomething isn't workingduckdbIssue is related to duckdb backend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions