关于mysql的日期时间类型

kissjhy 2015-08-24 03:38:38
20150824 093115.697
年月日 HHMMSS 毫秒
请教:我的数据时间格式是这样的
小数点后为毫秒
mysql该选择什么数据类型啊?
...全文
145 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Rotel-刘志东 2015-08-26
  • 打赏
  • 举报
回复
用varchar
侯爵123 2015-08-26
  • 打赏
  • 举报
回复
varchar
ACMAIN_CHM 2015-08-26
  • 打赏
  • 举报
回复
varchar
benluobo 2015-08-24
  • 打赏
  • 举报
回复
mysql 5.6 官方开发文档
kissjhy 2015-08-24
  • 打赏
  • 举报
回复
引用 1 楼 benluobobo 的回复:
A DATETIME or TIMESTAMP value can include a trailing fractional seconds part in up to microseconds (6 digits) precision. In particular, as of MySQL 5.6.4, any fractional part in a value inserted into a DATETIME or TIMESTAMP column is stored rather than discarded. With the fractional part included, the format for these values is 'YYYY-MM-DD HH:MM:SS[.fraction]', the range for DATETIME values is '1000-01-01 00:00:00.000000' to '9999-12-31 23:59:59.999999', and the range for TIMESTAMP values is '1970-01-01 00:00:01.000000' to '2038-01-19 03:14:07.999999'. The fractional part should always be separated from the rest of the time by a decimal point; no other fractional seconds delimiter is recognized. For information about fractional seconds support in MySQL, see Section 11.3.6, “Fractional Seconds in Time Values”.
谢谢,文档出自哪里?
道玄希言 2015-08-24
  • 打赏
  • 举报
回复

既然你保存的是时间, 可以直接用 DATETIME 的, 这样对于你以后查询啊什么的, 都会方便很多了。

如果你一定要表示成  20150824 093115.697  这样, 那用varchar(19)  可以保存。

但是到之后要用这个字段做条件进行条件查询,或者统计啥的,就有你受的了。

benluobo 2015-08-24
  • 打赏
  • 举报
回复
A DATETIME or TIMESTAMP value can include a trailing fractional seconds part in up to microseconds (6 digits) precision. In particular, as of MySQL 5.6.4, any fractional part in a value inserted into a DATETIME or TIMESTAMP column is stored rather than discarded. With the fractional part included, the format for these values is 'YYYY-MM-DD HH:MM:SS[.fraction]', the range for DATETIME values is '1000-01-01 00:00:00.000000' to '9999-12-31 23:59:59.999999', and the range for TIMESTAMP values is '1970-01-01 00:00:01.000000' to '2038-01-19 03:14:07.999999'. The fractional part should always be separated from the rest of the time by a decimal point; no other fractional seconds delimiter is recognized. For information about fractional seconds support in MySQL, see Section 11.3.6, “Fractional Seconds in Time Values”.

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧