Skip to content

Support DuckDB's EXTRACT('hour' FROM timestamp) syntax #1983

@ryanschneider

Description

@ryanschneider

DuckDB allows both "string" and identifier values for the part in its EXTRACT(part FROM date) function: https://duckdb.org/docs/stable/sql/functions/date.html#extractpart-from-date

For example:

> duckdb
DuckDB v1.3.0 (Ossivalis) 71c5c07cdd
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D SELECT EXTRACT('hour' FROM current_localtimestamp());
┌──────────────────────────────────────────────────┐
│ main.date_part('hour', current_localtimestamp()) │
│                      int64                       │
├──────────────────────────────────────────────────┤
│                        9                         │
└──────────────────────────────────────────────────┘

However the parser fails on this syntax w/ error: ParserError("Expected: date/time field, found: 'hour'")

Metadata

Metadata

Assignees

No one assigned

    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