当前位置:Gxlcms > 数据库问题 > MySQL中TIMESTAMPDIFF和TIMESTAMPADD函数的用法

MySQL中TIMESTAMPDIFF和TIMESTAMPADD函数的用法

时间:2021-07-01 10:21:17 帮助过:6人阅读

select TIMESTAMPDIFF(day,2012-08-24,2012-08-30); +----------------------------------------------+ | TIMESTAMPDIFF(day,2012-08-24,2012-08-30) | +----------------------------------------------+ | 6 | +----------------------------------------------+ 1 row in set (0.00 sec)

 

mysql> select TIMESTAMPDIFF(MINUTE,2012-08-24 09:00:00,2012-08-30 12:00:00);  
+-------------------------------------------------------------------+  
| TIMESTAMPDIFF(MINUTE,2012-08-24 09:00:00,2012-08-30 12:00:00) |  
+-------------------------------------------------------------------+  
|                                                              8820 |   
+-------------------------------------------------------------------+  
1 row in set (0.01 sec)  

 

TIMESTAMPADD


 

语法: TIMESTAMPADD(interval,int_expr,datetime_expr)   说明: 将整型表达式int_expr 添加到日期或日期时间表达式 datetime_expr中。式中的interval和上文中列举的取值是一样的。  
mysql> select TIMESTAMPADD(MINUTE,8820,2012-08-24 09:00:00);  
+-------------------------------------------------+  
| TIMESTAMPADD(MINUTE,8820,2012-08-24 09:00:00) |  
+-------------------------------------------------+  
| 2012-08-30 12:00:00                             |   
+-------------------------------------------------+  
1 row in set (0.00 sec)  

 

来自:http://blog.csdn.net/zmxiangde_88/article/details/8011661

MySQL中TIMESTAMPDIFF和TIMESTAMPADD函数的用法

标签:datetime   csdn   sdn   函数   min   time   class   语法   sql   

人气教程排行