转换数据时间并插入MySQL [英] Convert datatime and insert in MySQL
本文介绍了转换数据时间并插入MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须导入包含12万行的CVS文件。前6列分别包含日期和时间,即:年,月,日,时,分,秒。
I have to import a CVS file containing 120k rows. The first 6 columns contain the date and time separately, ie: year, month, day, hour, minutes, seconds.
我将它们导入Java:
I imported them into Java:
int year = 2016
int month = 5
int day = 23
int hour = 15
int minutes = 57
int seconds = 22
如何将这种格式转换为
我也有一个GMT列,即 GMT +0200。我也可以在DATETIME转换此数据吗?
I also have a GMT column, i.e. "GMT +0200". Can I convert this data too in a DATETIME?
推荐答案
您可以通过以下方式构建字符串:
One way you could do this is to build your string in this format:
yyyy-MM-DD HH:mm:ss
yyyy-MM-DD HH:mm:ss
然后将其插入。
插入到您的表值中('2016-05-23 15:57:22')
INSERT INTO yourtable VALUES('2016-05-23 15:57:22')
这篇关于转换数据时间并插入MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文