如何在Mysql中存储大于24小时的时间? [英] How to store time greater than 24 Hours in Mysql?

查看:656
本文介绍了如何在Mysql中存储大于24小时的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个列(例如idletime),该列将存储小时值小于或大于24的时间值.当我尝试插入大于24的值时(对于 例如'80:00:00','129:23:12'等),正在获取以下错误代码:

I need to create a column (say idletime) that will store time value having hours smaller or bigger than 24. When i try to insert such values bigger than 24 (For example '80:00:00', '129:23:12', etc) , am getting the following error code:

java.sql.SQLException: Illegal hour value '80' for java.sql.Time type in value '80:00:00.
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
.....

我已经在Internet上进行搜索,发现TIME数据类型的范围是00:00:00到23:59:59,并且没有达到24:00:00.

I have searched over the Internet and found that the TIME datatype ranges from 00:00:00 to 23:59:59 and does not reach 24:00:00.

有什么解决方案可以解决我的问题吗?正在存储过程中执行此插入查询.

Is there any solution available for my problem? Am executing this insert query within a stored procedure.

推荐答案

由于异常" java.sql.SQLException "的性质,看来您的sql客户端有问题.

It seems that you have a problem from your sql client because of the nature of the exception "java.sql.SQLException".

  • 在裸机控制台或另一个sqlclient中进入并尝试执行什么 你正在尝试做
  • Go in in a bare console or another sqlclient and try to execute what you were trying to do

例如:

CREATE Table mytimetable (testtime TIME);

Insert into mytimetable values ('1:1:1'),('080:1:1'),('80:1:1');

select * from mytimetable ;
01:01:01
80:01:01
80:01:01

MySQL使用'HHH:MM:SS'格式,该格式大于24小时. 有关更多信息,请参见 doc .

MySQL uses the 'HHH:MM:SS' format, which is larger than 24 hours. See doc for more

这篇关于如何在Mysql中存储大于24小时的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆