Is there any difference between DATE_SUB() and using arithmetic operators for datetime calculation?

后端 未结 2 1637
小鲜肉
小鲜肉 2021-02-13 12:07

After I have seen a lot of questions here using the DATE_SUB() or DATE_ADD() functions instead of the arithmetic operators + or -

2条回答
  •  梦如初夏
    2021-02-13 12:40

    For me, it is a matter of experience. After dealing with multiple editors, libraries, and tools that manipulate databases, I've learned not to trust the "+" and "-" operators as much as I trust DATE_SUB(). It's a lot less likely that something is going to be accidentally broken as part of the next software upgrade with DATE_SUB(), when compared to using +/-

提交回复
热议问题