开发者

How to save Excel date time cell into MySQL using VBA?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜