calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hongbin ma <mahong...@apache.org>
Subject a question about timestampadd month
Date Thu, 16 Feb 2017 06:16:12 GMT
hi experts

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:

*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> *

I checked ANSI SQL 92, seems there's no definition on this.
Is this an issue we should concern? Looks like mysql's approach is more
straigthtforward.


-- 
Regards,

*Bin Mahone | 马洪宾*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message