The mysql table has a DATETIME field. I want to INSERT a new row into this field using the cell data from 开发者_开发百科the Excel worksheet. But I cannot use the datetime formatted cell value in a INSERT INTO query. How can I implement this?
Clarifying how you are using VBA would be helpful, but assuming that you are using VBA primarily to bring the data up to MySQL, you can handle a lot of your formatting right in your Excel workbook. For DATE type data,
=TEXT([the data],"YYYYMMDD")
is effective.
For DATETIME type data,
=TEXT([the data],"YYYYMMDDHHMMSS")
gets interpreted correctly at import by MySQL.
Hope that helps!
You could create a custom format that represents the datetime in the correct way.
精彩评论