kraadde Posted January 3, 2007 Share Posted January 3, 2007 I have a problem. I programmed a query to check whether a database field containing a year value (typ varchar(4)) is within a given intervals. The script is like that: $sqlAB="SELECT ......, year FROM .... WHERE ..... AND year >= '$txYearFrom' AND year <= '$txYearTo' AND .... order by ..."; $txYearFrom .. To are a text strings which I read out from input fields like that: <input name="txYearFrom" type="text"> The query result is sometimes wrong. How can I fix that and get reliable results? Btw the database structure can not be changed... Thanks all for a good idea... Adriano [email protected] Link to comment https://forums.phpfreaks.com/topic/32682-prob-with-date-query/ Share on other sites More sharing options...
trq Posted January 3, 2007 Share Posted January 3, 2007 Dont store dates as VARCHAR. You'll need to use one of the date/time types. Read [url=http://mysql.org/doc/refman/5.1/en/date-and-time-types.html]here[/url] for more info. Link to comment https://forums.phpfreaks.com/topic/32682-prob-with-date-query/#findComment-152106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.