unix_timestamp 和 from_unixtime 时间戳函数 区别
1.unix_timestamp
将时间转化为时间戳。(date 类型数据转换成 timestamp 形式整数)
没传时间参数则取当前时间的时间戳
mysql> select unix_timestamp();
+------------------+
| unix_timestamp() |
+------------------+
| 1361586358 |
+------------------+
1 row in set (0.01 sec)
mysql> select unix_timestamp('2013-01-01 10:10:10');
+---------------------------------------+
| unix_timestamp('2013-01-01 10:10:10') |
+---------------------------------------+
| 1357006210 |
+---------------------------------------+
1 row in set (0.00 sec)
2.from_unixtime
将timestamp 形式整数 转化为 date类型
mysql> select from_unixtime(1355272360);
+---------------------------+
| from_unixtime(1355272360) |
+---------------------------+
| 2012-12-12 08:32:40 |
+---------------------------+
1 row in set (0.00 sec)
当然也可以指定输出的时间格式:
mysql> select from_unixtime(1355272360,'%Y%m%d');
+------------------------------------+
| from_unixtime(1355272360,'%Y%m%d') |
+------------------------------------+
| 20121212 |
+------------------------------------+
3.关于mysql 时间戳的限制
目前timestamp 所能表示的范围在 1970 - 2038之间 。
超过这个范围 得到的时间将会溢出 得到的时间是null.
mysql> select from_unixtime(0);
+---------------------+
| from_unixtime(0) |
+---------------------+
| 1970-01-01 08:00:00 |
+---------------------+
mysql> select from_unixtime(2147483647);
+---------------------------+
| from_unixtime(2147483647) |
+---------------------------+
| 2038-01-19 11:14:07 |
+---------------------------+
1 row in set (0.00 sec)
unix_timestamp 和 from_unixtime 时间戳函数 区别的更多相关文章
- mysql 中 unix_timestamp和from_unixtime 时间戳函数
1.unix_timestamp 将时间转化为时间戳.(date 类型数据转换成 timestamp 形式整数) 没传时间参数则取当前时间的时间戳 mysql> select unix_time ...
- hive 时间戳函数之unix_timestamp,from_unixtime
一. 日期>>>>时间戳 1.unix_timestamp() 获取当前时间戳 例如:select unix_timestamp() -- 2.unix_timestamp(s ...
- FROM_UNIXTIME 格式化MYSQL时间戳函数
FROM_UNIXTIME 格式化MYSQL时间戳函数 对MYSQL没有进行过深入的研究,基础知识匮乏,一遇到问题只能手册,看来要把MYSQL的学习安排进时间表了. 函数:FROM_UNIXTIME作 ...
- MySql UNIX_TIMESTAMP和FROM_UNIXTIME函数讲解
MySql UNIX_TIMESTAMP和FROM_UNIXTIME函数讲解 by:授客 QQ:1033553122 1. unix_timestamp(date)将时间转换为时间戳,如果参数为空,则 ...
- unix_timestamp 时间戳函数用法(hive)
pandas和SQL数据分析实战 https://study.163.com/course/courseMain.htm?courseId=1006383008&share=2&sha ...
- 给PostgreSQL添加MySQL的unix_timestamp与from_unixtime函数
MySQL的2个常用函数unix_timestamp()与from_unixtime PostgreSQL并不提供,但通过PostgreSQL强大的扩展性可以轻松的解决问题. 话说远在天边,尽在眼前, ...
- SQL Server时间粒度系列----第6节基于当前日的小时数和分钟数与mysql unix_timestamp和from_unixtime的mssql实现
本文目录列表: 1.基于当前日的小时数和分钟数2.mysql unix_timestamp和from_unixtime的mssql实现 3.总结语 4.参考清单列表 基于当前日的小时数和分钟数 ...
- MySQL 获得当前日期时间\时间戳 函数 ( 转自传智播客)
MySQL 获得当前日期时间 函数 1.1 获得当前日期+时间(date + time)函数:now() mysql> select now(); +-------+ | now() | +-- ...
- MySQL 获得当前日期时间\时间戳 函数
MySQL 获得当前日期时间 函数 1.1 获得当前日期+时间(date + time)函数:now() mysql> select now(); +———————+ | now() | +—— ...
随机推荐
- Atitit php序列化 php的serialize序列化和json序列化
Atitit php序列化 php的serialize序列化和json序列化 PHP 对不同类型的数据用不同的字母进行标示,Yahoo 开发网站提供的Using Serialized PHP with ...
- mysql only_full_group_by问题
我的mysql出现了only_full_group_by问题,网上一堆处理方案! 主要两种 一种修改配置表my.ini 另一种通过指令,屏蔽当前链接的only_full_group_by报错!我想永久 ...
- C++游戏系列5:不止有一件武器
很多其它见:C++游戏系列文件夹 知识点:对象数组作为数据成员 改进:每一个角色所持有的武器不仅仅一件,故持有的武器,用了对象数组来表示,当然,也能够是空手. 由此而带来的,还得记录一共同拥有几件武器 ...
- Redis-ha(sentinel)
redis的sendtinel 是用来管理多个redis服务器的 作用 • 监控:监控主从服务器是否运作正常(通过给服务器发送心跳包的方式) • 提醒:当某个Redis服务器出现异常时,可以通过 ...
- 使用struts的时候form用struts的,不用html本身的
同样的struts-config.xml, web.xml的配置,使用2个版本的form,只有struts的form才能成功运行 使用html版本的form导致post的路径不对,报404 HTML版 ...
- SqlServer2005删除实例
控制面板->选中“SQL Server 2005”卸载,卸载的时候可以选择实例.
- bzoj2440 完全平方数 莫比乌斯值+容斥+二分
莫比乌斯值+容斥+二分 /** 题目:bzoj2440 完全平方数 链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2440 题意:求第k个小x数 ...
- UVA 12034 Race (递推神马的)
Disky and Sooma, two of the biggest mega minds of Bangladesh went to a far country. They ate, coded ...
- linux命名对文件的读写和退出
vi xxx.txt 打开就能看到里面的内容.按 i 进入编辑模式,然后就可以输入内容了,也可以移动光标到你要删除内容的位置按删除键来删除内容.编辑完后可以按 Esc(键盘左上角) 进入命令模式.然后 ...
- C++ 类的继承五(类继承中的static关键字)
//类继承中的static关键字 #include<iostream> using namespace std; /* 派生类中的静态成员 基类定义的静态成员,将被所有派生类共享 根据静态 ...