Closed BohuTANG closed 3 weeks ago
I would like to have a try.
select to_date('2024-02-29') + - to_date('2025-02-28');
be valid or invalid? I mean the add operation between two date.
- Should
select to_date('2024-02-29') + - to_date('2025-02-28');
be valid or invalid? I mean the add operation between two date.
select to_date('2024-02-29') - to_date('2025-02-28'); is valid.
select to_date('2024-02-29') + to_date('2025-02-28'); is invalid.
Summary
Databend lacks a DATE_DIFF function, though it supports direct arithmetic on dates and times (e.g., TO_DATE(NOW()) - 2 for two days ago). However, users may find this conversion difficult, see: https://docs.databend.com/sql/sql-functions/datetime-functions/date-diff
Proposal add a
DATE_DIFF
function:Similar to Snowflake's DATEDIFF function, this will simplify date and time arithmetic for users.