How to convert a string from a spreadsheet to date format for mysql?

Asked

Viewed 148 times

1

I’m taking a spreadsheet excel in date format but in the database inserts as string in text format in excel despite this in date

try to convert by mysql however in Insert appears the following column error

'cannot be null column name

follows the Insert

$salesplan_insert = mysqli_query($link,"insert into prom.absenteismo(`matricula` , `funcionario` , `lider` , `linha` , `falta`, `data_falta`, `observacao`) values ('$a','$b','$c','$d','$e', date_format('$f', '%Y-%m-%d'),'$g')");

I’ve also used the STR_TO_DATE() also did not work someone knows how to do this?

  • Could you show the contents of the variables being used in the query? Be careful too, as your query is vulnerable to sql injection

  • the variable $f appears 42803 but in the spreadsheet this date 9/9/2017

  • @claudomarso Excel works with numbers that are transformed into date for user viewing. It would be necessary or convert everything into text and then its Insert would be correct or it will be necessary to treat this date so that it is extracted in the date of fact format and not the code 42803 that Excel understands as date. I hope to have helped.

  • i tried it in php this way date('Y/m/d', strtotime($f)); but it comes with a date of 1969

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.