假设今天是 11 月 2 日...
我有这张表:
|--------|----------|------------|
| SUB_Id | SUB_Name | SUB_End |
|--------|----------|------------|
| 1 | Banana | 2017-11-02 | <- return this row (diff 0 day)
| 2 | Apple | 2017-11-03 | <- return this row (diff 1 day)
| 3 | Pear | 2017-11-09 | < don't return this row as diff is > 3
|--------|----------|------------|
我使用此查询来获取 SUB_End
- 今天日期 <= 3 时的行。
SELECT * FROM Subscriptions WHERE SUB_End >= curdate() AND SUB_TrialEnd <= curdate() + interval 15 day
如何获得从此查询计算出的差异?
例如,对于行
最佳答案
尝试 mySQL 中的 DateDiff 函数。请参阅here
关于mysql - 在查询中使用运算符通过 mySQL 获取两个日期之间的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47077122/