mardi 28 juin 2016

Date stored in varchar format. Result issue


Sorry for my poor technical English. I try to get some data from my db between now with 1 month interval.

This query work perfectly (221 rows returns)

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"))

I want return the row from last month only. I have tried BETWEEN fonction but my field "dateModification" is in VARCHAR format ( "06/02/2012 13:55:09") so i have a result : Truncated incorrect date value: "06/06/2016 13:55:09"

How i can modify this query to have a rows from the last 30 days only ?


Aucun commentaire:

Enregistrer un commentaire