You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "hongbin ma (JIRA)" <ji...@apache.org> on 2017/04/17 03:43:41 UTC
[jira] [Commented] (CALCITE-1639) timestampadd month should return
result month's last day when day part overflow
[ https://issues.apache.org/jira/browse/CALCITE-1639?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15970645#comment-15970645 ]
hongbin ma commented on CALCITE-1639:
-------------------------------------
During working on the issue I found an interesting constant: org.apache.calcite.avatica.util.DateTimeUtils#EPOCH_JULIAN, which seems to be related with 4800 BC. What is the retionale behind the design? I don't quite understand it
> timestampadd month should return result month's last day when day part overflow
> -------------------------------------------------------------------------------
>
> Key: CALCITE-1639
> URL: https://issues.apache.org/jira/browse/CALCITE-1639
> Project: Calcite
> Issue Type: Bug
> Reporter: hongbin ma
> Assignee: Julian Hyde
> 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
(v6.3.15#6346)