gpt4 book ai didi

mysql - 以 varchar 格式存储的日期。结果问题

转载 作者:行者123 更新时间:2023-11-28 23:29:12 26 4
gpt4 key购买 nike

抱歉我的技术英语不好。从现在开始,我尝试以 1 个月的间隔从我的数据库中获取一些数据。

此查询完美运行(返回 221 行)

SELECT idEcare,reference 
FROM DEMS
WHERE (((etatSuivant ="Etat_ADM_131276535415392&SURF=Transmis")
OR (etatSuivant = "Etat_ADM_121276535415390&SURF=Traitement en cours")
OR (etatSuivant = "Etat_ADM_11276535415374&SURF=A l étude")
OR (etatSuivant = "Etat_ADM_81276535415384&SURF=Programmé"))
AND ((categorisation LIKE "%Propreté:Tas sauvage%")
OR (categorisation LIKE "%Circulation et stationnement:Véhicule gênant%")
OR (categorisation LIKE "%Circulation et stationnement:Véhicule ventouse_Epave_Brûlé%")
OR (categorisation LIKE "%Propreté:Passage ponctuel%")
OR (categorisation LIKE "%Propreté:Corbeille pleine%")
OR (categorisation LIKE "%Propreté:Huile_Verre cassé%")
OR (categorisation LIKE "%Propreté:Désherbage_Feuilles mortes%")
OR (categorisation LIKE "%Propreté%")
OR (categorisation LIKE "%Espace Vert:Entretien des massifs:Nettoyage%")
OR (categorisation LIKE "%Mobilier urbain:Corbeille:Réparation%"))
AND (confidentialite = "Non"))

我只想返回上个月的行。我试过 BETWEEN 函数,但我的字段“dateModification”是 VARCHAR 格式(“06/02/2012 13:55:09”)所以我得到一个结果:截断不正确的日期值:“06/06/2016 13:55: 09"

我如何修改此查询以仅包含过去 30 天的行?

最佳答案

看起来不错

SELECT idEcare,reference 
FROM DEMS
WHERE (((etatSuivant IN ("Etat_ADM_131276535415392&SURF=Transmis", ...
AND STR_TO_DATE(dateModification, "%d/%m/%Y %H:%i:%s") >= DATE_SUB(NOW(), INTERVAL 1 MONTH)

谢谢马特

关于mysql - 以 varchar 格式存储的日期。结果问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37963097/

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