我当前的输入表如下所示
Current_Day billing_day
Oct-13 14
Oct-13 15
Oct-13 16
Oct-13 1
Oct-13 8
Oct-13 12我希望得到的表格如下所示
Current_Day billing_day Start_date End_date
Oct-13 14 Oct-13 oct-14
Oct-13 15 Oct-13 oct-15
Oct-13 16 Oct-13 oct-16
Oct-13 1 Oct-13 nov-1
Oct-13 8 Oct-13 nov-8
Oct-13 12 Oct-13 nov-12在MySQL中有没有实现这一点的方法或函数?
编辑:
如果billing_day为14,则应显示最接近的日历日期。例如: 14表示10月14日,1表示11月1日,因为10月1日已经过去。
结果End_date不应该是billing_day + Current_day的相加
它应该遵循当前日历
发布于 2016-10-13 18:41:41
在数据库中,不要使用字符串来表示日期,应该使用TimeStamp。
https://dev.mysql.com/doc/refman/5.5/en/datetime.html
函数日期和时间
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
https://stackoverflow.com/questions/40018564
复制相似问题