Skip to content

MySQL allows integer interval values #298

Closed

Description

@duvall-eb

The usual format for an interval is INTERVAL 'value' unit, but MySQL allows 'value' to be an expression that is either a string or a number. For example:

SELECT DATE_SUB('2018-05-01',INTERVAL '1' YEAR);
SELECT DATE_SUB('2018-05-01',INTERVAL 1 YEAR);

both return 2017-05-01. Currently, the latter syntax is not supported.

Activity

  1. kyle-mccarthy commented on Mar 16, 2022

    @kyle-mccarthy

    I am running into this issue as well. mysql also allows for referencing columns in the unit part of the interval.

  2. 46bit commented on Jun 9, 2022

    @46bit

    ClickHouse similarly supports INTERVAL 1 HOUR without requiring the 1 to be quoted. I'm not sure it supports generic expressions though, just unquoted numbers. https://clickhouse.com/docs/en/sql-reference/operators/#interval

  3. LucaCappelletti94 commented on Sep 22, 2026

    @LucaCappelletti94
    Contributor

    Closing as resolved in #517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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