python - truncated incorrect value -


i have python code displays range of dates. in code below have passed dates in select operation casting dates , using str_to_date function. want know how range of values start , end date can passed in query below. want achieve give range of dates , script should find dates in mysql table , display dates.the date column in mysql varchar type.so need convert varchar date , use between operator range of dates.following code snippet:

import mysqldb import os,sys import datetime  path="c:/python27/" conn = mysqldb.connect (host = "localhost",user = "root", passwd = "cimis",db = "cimis") c = conn.cursor()  message = """select stationid,date,hour,airtemperature cimishourly  date between cast((select str_to_date('5/16/2011 ', '%c/%e/%y')) date) , cast((select str_to_date('5/18/2011 ', '%c/%e/%y'))  date)""" c.execute(message,) result=c.fetchall() row in result:     print(row) conn.commit() c.close() 

the error message is:truncated incorrect date value '6/8/1982'

the correct way convert date varchar date datatype , perform select operation shown:

message = """select stationid,datecol,airtemperature cimishourly str_to_date(datecol, '%m/%d/%y') between str_to_date('8/10/2015', '%m/%d/%y') , str_to_date('8/12/2015', '%m/%d/%y') , stationid in (2)"""


Comments