Database Query Displaying Date 0000-00-00

Topics: Developer Forum, Project Management Forum, User Forum
Sep 27, 2012 at 6:45 PM
Edited Sep 27, 2012 at 6:47 PM

I am trying to insert a date into MySql database and for some strange reason it is not inserting correctly. The date in my spreadsheet reads 9/23/2012....and after I run my query and check the database the date field reads as 0000-00-00. I looked in the documentation and I didn't find a fix for this. Maybe I skipped over what I need while searching. What am I doing wrong or not doing at all. Also could someone point me to what I need in the documentation? With that said, here is my code for my date statement...

 

 

 

$EffectiveDate =  $worksheet->getCellByColumnAndRow(2,$row)->getFormattedValue();

Sep 27, 2012 at 7:19 PM

9/23/2012 is what you see in excel or what you see in php after the reading?

in first case, it can be an excel date and phpexcel has methods to convert it to "php ready" dates

in second case, this is not a phpexcel problem, do a little of debugging on your code managing mysql (for example, look at the query text, try it in phpmyadmin, try to understand if the format of the date you are passing is ok for the date field and so on)

Sep 27, 2012 at 7:19 PM

9/23/2012 is what you see in excel or what you see in php after the reading?

in first case, it can be an excel date and phpexcel has methods to convert it to "php ready" dates

in second case, this is not a phpexcel problem, do a little of debugging on your code managing mysql (for example, look at the query text, try it in phpmyadmin, try to understand if the format of the date you are passing is ok for the date field and so on)

Sep 27, 2012 at 7:40 PM

I see the date 9/23/2012 in the spreadsheet and in the html view! But yea Im going to go back to the drawing board!

Sep 28, 2012 at 1:50 PM

yes i think you should check your query text :)

Sep 28, 2012 at 2:02 PM

Hey guys, 

           I found a fix to my problem this morning! What I did was customize the format on my date fields in my excel spreadsheet. After I made that change MySql recognized the format. Hope this helps others!