【发布时间】:2016-10-13 10:33:16
【问题描述】:
我当前的输入表如下所示
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 表示 oct-14,1 表示 Nov-1,因为 oct-1 已经过去了。
结果 End_date 不应是 billing_day + Current_day 的加法
它应该遵循当前日历
【问题讨论】:
-
End_date来自哪里?好的。知道了。你想在表格中更新它还是仅仅显示? -
End_date 必须来自 billing_day,例如:14 变为 oct-14
-
显示并更新到表格:)
-
我已经更新了我的答案。看看有没有帮助。