gpt4 book ai didi

php - 使用自定义日期检索最近 3 年的数据

转载 作者:行者123 更新时间:2023-12-01 00:40:17 25 4
gpt4 key购买 nike

这是我的查询:

mysql> select * from jobs where datediff(now(),str_to_date(last_modified,'%M %d,%Y'))>=1095;

我得到 0 个结果

mysql> 从作业中选择 max(last_modified);

+--------------------+
| max(last_modified) |
+--------------------+
| 9/9/2013 |
+--------------------+
1 row in set (0.06 sec)

mysql>

它似乎运行不佳,我不确定为什么。 我认为这与 last_modified 列的原始格式有关

更新

mysql> select distinct(last_modified) from jobs where datediff(now(),str_to_date(last_modified,'%m/%d/%Y'))>=1095 limit 10;

+---------------+
| last_modified |
+---------------+
| 12/4/2003 |
| 12/5/2003 |
| 12/6/2003 |
| 12/8/2003 |
| 12/9/2003 |
| 12/10/2003 |
| 12/11/2003 |
| 12/12/2003 |
| 12/13/2003 |
| 12/14/2003 |
+---------------+
10 rows in set (0.00 sec)

mysql>

最佳答案

使用 str_to_date(last_modified,'%m/%d/%Y') 而不是 str_to_date(last_modified,'%M %d,%Y')

关于php - 使用自定义日期检索最近 3 年的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34321923/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com