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() | +—— ...
随机推荐
- 点滴积累【JS】---JS小功能(setInterval实现图片效果显示时间)
效果: 代码: <head runat="server"> <title></title> <script type="text ...
- atitit.userService 用户系统设计 v5 q330
atitit.userService 用户系统设计 v5 q330 1. 新特性1 2. Admin login1 3. 用户注册登录2 3.1. <!-- 会员注册使用 --> 商家 ...
- C++语言基础(20)-模板的非类型参数
一.在函数模板中使用非类型参数 #include <iostream> using namespace std; template<class T> void Swap(T & ...
- mongodb 安装部署说明
mongodb.conf 配置文件 # Where the databases will be stored dbpath=/usr/local/mongodb/mongodb-/data/db # ...
- php 36进制与10进制转换
php 36进制与10进制转换 /** * @desc im:十进制数转换成三十六机制数 * @param (int)$num 十进制数 * return 返回:三十六进制数 */ function ...
- ORACLE 中 TRANSLATE的用法
--TRANSLATE(string,from_str,to_str) --to_str和from_str中的字符一一对应 --如果string里有,from_str字符集里没有的字符,将保留 --如 ...
- .net访问Oracle数据库
使用System.Data.OracleClient访问Oracle数据库时报错 尝试加载 Oracle 客户端库时引发 BadImageFormatException.如果在安装 32 位 Orac ...
- scala读写文件
def main(args: Array[String]): Unit = { //1 read for( i<- Source.fromFile("test.dat").g ...
- hihoCoder #1291 : Building in Sandbox 逆向处理+并查集维护
/** 题目:#1291 : Building in Sandbox 链接:https://hihocoder.com/problemset/problem/1291 题意:就是一个三维的空间里,按照 ...
- (转)Python爬虫学习笔记(2):Python正则表达式指南
以下内容转自CNBLOG:http://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html 1. 正则表达式基础 1.1. 简单介绍 正则表达式并 ...