SQL 将 Int 转换为时间
我正在尝试将数据从文本文件导入到 SQL 数据库。该文件使用 TAB not 来分隔字段。我的导入问题是,当我编写以 Int 形式给出的时间时,它在导入时完全搞乱了。
文本文件的一部分:
North Felix 2011-07-01 0422 0.47 0012 0.69 2109 0.55 1311 1.44 North Felix 2011-07-02 0459 0.43 0048 0.72 2140 0.55 1342 1.47 North Felix 2011-07-03 0533 0.41 0123 0.75 2213 0.57 1412 1.46 North Felix 2011-07-04 0605 0.41 0158 0.79 2244 0.59 1441 1.41
我的查询结果:
INSERT INTO `dbc`.`history_long` (`Region`,`Location`,`Date`,`LT1-time`,`LT1-height`,`HT1-time`,`HT1-height`,`LT2-time`,`LT2-height`,`HT2-time`,`HT2-height`)
values ('North','Felix','2011:00:00','422:00:00','0.47','12:00:00','0.69','2109:00:00','0.55','1311:00:00','1.44'),
('North','Felix','2011:00:00','459:00:00','0.43','48:00:00','0.72','2140:00:00','0.55','1342:00:00','1.47'),
('North','Felix','2011:00:00','533:00:00','0.41','123:00:00','0.75','2213:00:00','0.57','1412:00:00','1.46'),
('North','Felix','2011:00:00','605:00:00','0.41','158:00:00','0.79','2244:00:00','0.59','1441:00:00','1.41'),
问题是例如 L2-time 在时间列中变为 2109:00:00。有没有办法将其从 Int 转换为 Time?
i'm trying to import data from a text file to an SQL database. The file is using TAB not , to separate fields. My issue on import has been that when I write the Time which is given as an Int it completely messes up on import.
Part of the text file:
North Felix 2011-07-01 0422 0.47 0012 0.69 2109 0.55 1311 1.44 North Felix 2011-07-02 0459 0.43 0048 0.72 2140 0.55 1342 1.47 North Felix 2011-07-03 0533 0.41 0123 0.75 2213 0.57 1412 1.46 North Felix 2011-07-04 0605 0.41 0158 0.79 2244 0.59 1441 1.41
My query result:
INSERT INTO `dbc`.`history_long` (`Region`,`Location`,`Date`,`LT1-time`,`LT1-height`,`HT1-time`,`HT1-height`,`LT2-time`,`LT2-height`,`HT2-time`,`HT2-height`)
values ('North','Felix','2011:00:00','422:00:00','0.47','12:00:00','0.69','2109:00:00','0.55','1311:00:00','1.44'),
('North','Felix','2011:00:00','459:00:00','0.43','48:00:00','0.72','2140:00:00','0.55','1342:00:00','1.47'),
('North','Felix','2011:00:00','533:00:00','0.41','123:00:00','0.75','2213:00:00','0.57','1412:00:00','1.46'),
('North','Felix','2011:00:00','605:00:00','0.41','158:00:00','0.79','2244:00:00','0.59','1441:00:00','1.41'),
The issue is for example L2-time becomes 2109:00:00 in the time column. Is there a way to convert this from Int to Time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是将
0422
这样的int
转换为time
值:如果没有看到导入查询,就不可能说出如何实际应用它。
Here's how you could convert an
int
like0422
to atime
value:Without seeing your import query it's impossible to say how you could actually apply it.