[
https://issues.apache.org/jira/browse/CALCITE-1639?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17677098#comment-17677098
]
Julian Hyde commented on CALCITE-1639:
--------------------------------------
In commit
[e47b43ee|https://github.com/apache/calcite-avatica/commit/e47b43ee8c818cb2bf18649410cbd6b56f63fe8c]
this code is copied from Calcite to Avatica. In Avatica release 1.23 and
later, Calcite will be able to rely on Avatica's {{DateTimeUtils.addMonths}}
function.
> TIMESTAMPADD(MONTH, ...) should return last day of month if the day overflows
> -----------------------------------------------------------------------------
>
> Key: CALCITE-1639
> URL: https://issues.apache.org/jira/browse/CALCITE-1639
> Project: Calcite
> Issue Type: Bug
> Reporter: Hongbin Ma
> Assignee: Julian Hyde
> Priority: Major
> Fix For: 1.13.0
>
> Attachments:
> 0001-CALCITE-1639-deal-with-day-overflow-in-addmonth-with.patch
>
>
> in calcite,
> select timestampadd(MONTH,1,cast('2016-05-31' as timestamp)) will return
> 2016-07-01 00:00:00, and select timestampadd(MONTH,-1,cast('2016-03-31' as
> timestamp)) will return 2016-03-01 00:00:00
> however in mysql, the last day of the next/previous month is always returned:
> {noformat}
> mysql> select timestampadd(MONTH,1,'2016-05-31') ;
> +------------------------------------+
> | timestampadd(MONTH,1,'2016-05-31') |
> +------------------------------------+
> | 2016-06-30 |
> +------------------------------------+
> 1 row in set (0.00 sec)
> mysql> select timestampadd(MONTH,-1,'2016-03-31') ;
> +-------------------------------------+
> | timestampadd(MONTH,-1,'2016-03-31') |
> +-------------------------------------+
> | 2016-02-29 |
> +-------------------------------------+
> 1 row in set (0.00 sec)
> mysql>
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)