Mike SD Posted May 5, 2009 Share Posted May 5, 2009 Hello Everyone I was hoping someone could help me with a PHP MySQL CSV problem I am trying to create an online add-on for a program I use called ScheduleIt I export all of the data from the ScheduleIt program as a .csv file and import this into a MySQL database, then use PHP to display selected data The problem I am having is with the dates When exporting the data as a .csv file it exports the dates as general formatted text (2009/05/05 becomes 39938) I can open the .csv file in Excel and format the cells using a custom format (yyyy/mm/dd) then upload the data to my database But I want to eliminate this section I am trying to create some sort of code to format the dates It does not matter when the dates are formatted, all I want to do is search the database for a chosen date Does anyone know how this can be done? I have been searching the internet for weeks and have made no progress Thank you for your time Regards Michael Link to comment https://forums.phpfreaks.com/topic/156924-php-mysql-csv-problem/ Share on other sites More sharing options...
gnawz Posted May 5, 2009 Share Posted May 5, 2009 Any code? Link to comment https://forums.phpfreaks.com/topic/156924-php-mysql-csv-problem/#findComment-826620 Share on other sites More sharing options...
Yesideez Posted May 5, 2009 Share Posted May 5, 2009 If you can explain how/why the dates are being converted to the strange 5 digit number format that would also help. I've not seen that format before. Link to comment https://forums.phpfreaks.com/topic/156924-php-mysql-csv-problem/#findComment-826624 Share on other sites More sharing options...
Mike SD Posted May 5, 2009 Author Share Posted May 5, 2009 Any code? What code do you need? To import my .csv into my database I use: $sql = 'LOAD DATA LOCAL INFILE \'temp/schedule.csv\' REPLACE INTO TABLE `table` FIELDS TERMINATED BY \',\' ENCLOSED BY \'"\' ESCAPED BY \'\\\\\' LINES TERMINATED BY \'\\r\\n\' . ' '; $result=mysql_query($sql); To to display the data by date I use: $sql="SELECT * FROM $tbl_name WHERE DateStart <= '$filter' && DateEnd >= '$filter' ORDER BY ResourceName ASC"; Does this help? Link to comment https://forums.phpfreaks.com/topic/156924-php-mysql-csv-problem/#findComment-826626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.