Skip to content

fix!: duckdb week/quarter support#5374

Merged
georgesittas merged 1 commit intomainfrom
eakmanrq/duckdb_week_quarter_support
Jul 8, 2025
Merged

fix!: duckdb week/quarter support#5374
georgesittas merged 1 commit intomainfrom
eakmanrq/duckdb_week_quarter_support

Conversation

@eakmanrq
Copy link
Collaborator

@eakmanrq eakmanrq commented Jul 8, 2025

This logic was originally added in 2023: #1780

I can see quarter was at least added in 2024: duckdb/duckdb#11898

Tested and confirmed that 0.10.3 added quarter support and week support is in 0.10.2 so not sure when that was added.

The original logic actually has a bug for quarter since it converted a quarter to 90 days but that isn't correct when doing additions and subtractions to dates.

conn.execute("SELECT DATE_ADD(TIMESTAMP'2020-01-01 00:00:00', INTERVAL 1 QUARTER)").fetchall()
[(datetime.datetime(2020, 4, 1, 0, 0),)]
conn.execute("SELECT DATE_ADD(TIMESTAMP'2020-01-01 00:00:00', INTERVAL 90 DAY)").fetchall()
[(datetime.datetime(2020, 3, 31, 0, 0),)]

The previous week logic looks fine but isn't needed anymore:

conn.execute("SELECT INTERVAL (-5) WEEK").fetchall()
[(datetime.timedelta(days=-35),)]

Copy link
Owner

@tobymao tobymao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a breaking change

@eakmanrq eakmanrq changed the title fix: duckdb week/quarter support fix!: duckdb week/quarter support Jul 8, 2025
Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@georgesittas georgesittas merged commit d7ccb48 into main Jul 8, 2025
6 checks passed
@georgesittas georgesittas deleted the eakmanrq/duckdb_week_quarter_support branch July 8, 2025 05:42
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

Successfully merging this pull request may close these issues.

3 participants