whelpton Posted December 23, 2012 Share Posted December 23, 2012 Hey guys, First of all, thanks for reading my post, its much appreciated. I've been roped into trying to develop a system to work with a large CSV file, which I believe should be ported into a mysql db to start off with then processed via php. The only issue comes into searching through the DB and finding a specific date range, I am trying to use the mysql between code such as this: SELECT * FROM sample WHERE `order_date` >= "01/01/2010" and `order_date` < "30/12/2010" But I still get order_date's that are outside of that date range. Any ideas? Link to comment https://forums.phpfreaks.com/topic/272311-help-with-mysql-select-betweenwhere/ Share on other sites More sharing options...
Pikachu2000 Posted December 23, 2012 Share Posted December 23, 2012 Dates should be in YYYY-MM-DD format in the DB. Link to comment https://forums.phpfreaks.com/topic/272311-help-with-mysql-select-betweenwhere/#findComment-1401000 Share on other sites More sharing options...
whelpton Posted December 23, 2012 Author Share Posted December 23, 2012 Thanks for the reply PIkachu2000, Is there a way around this, as the data is imported from a 100/200mb csv file that would be a pain in the arse to manually change and I imagine a pain in my processor's arse to change through code Link to comment https://forums.phpfreaks.com/topic/272311-help-with-mysql-select-betweenwhere/#findComment-1401003 Share on other sites More sharing options...
Pikachu2000 Posted December 23, 2012 Share Posted December 23, 2012 Re-import it using MySQL's STR_TO_DATE() function to get the date in the right format, add a new field and UPDATE the date into the new field with STR_TO_DATE()in the proper format and use that field for the comparisons, or use STR_TO_DATE() on the values in your comparisons. Link to comment https://forums.phpfreaks.com/topic/272311-help-with-mysql-select-betweenwhere/#findComment-1401004 Share on other sites More sharing options...
PFMaBiSmAd Posted December 23, 2012 Share Posted December 23, 2012 I imagine a pain in my processor's arse to change through code It would be a total of one UPDATE query, without a WHERE clause, to convert the existing value and set a new column to the corresponding YYYY-MM-DD value, all at once. Link to comment https://forums.phpfreaks.com/topic/272311-help-with-mysql-select-betweenwhere/#findComment-1401007 Share on other sites More sharing options...
whelpton Posted December 23, 2012 Author Share Posted December 23, 2012 Thanks gents, much appreciated =) Link to comment https://forums.phpfreaks.com/topic/272311-help-with-mysql-select-betweenwhere/#findComment-1401009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.