格式化时间

  db2 格式化时间使用的 TO_CHAR(TIMESTAMP('2017-10-24 21:18:12'),'YYYY-MM-DD');

  测试sql:SELECT TO_CHAR(TIMESTAMP('2017-10-24 21:18:12'),'YYYY-MM-DD') FROM SYSIBM.DUAL;

计算时间差

  db2计算时间差使用

timestampdiff (<n>, char(  timestamp('2017-12-24 00:00:10')-  timestamp('2017-12-24 00:00:05')))

测试sql:

select timestampdiff (2, char(  timestamp('2017-12-24 00:00:10')-  timestamp('2017-12-24 00:00:05')))   from SYSIBM.DUAL;

对于 <n>,可以使用以下各值来替代,以指出结果的时间单位:  
1 = 秒的小数部分   
2 = 秒   
4 = 分   
8 = 时   
16 = 天  
32 = 周   
64 = 月   
128 = 季度
256 = 年

DB2--sql计算时间差和格式化时间的更多相关文章

  1. SQL计算时间差并排除周末

    SQL计算时间差并排除周末 CREATE FUNCTION DI_FN_GET_WorkDay (@begin DATETIME , @end DATETIME ) RETURNS int BEGIN ...

  2. php计算时间差/两个时间日期相隔的天数,时,分,秒.

    function timediff( $begin_time, $end_time ) { if ( $begin_time < $end_time ) { $starttime = $begi ...

  3. java计算时间差及比较时间大小(转)

    比如:现在是2004-03-26 13:31:40        过去是:2004-01-02 11:30:24 我现在要获得两个日期差,差的形式为:XX天XX小时XX分XX秒 方法一: DateFo ...

  4. SQL计算时间差,要精确到小时分钟秒

    declare @starttime as datetime declare @endtime as datetime set @starttime = '2009-11-24 15:10:00' s ...

  5. [转]Sql server2005中如何格式化时间日期

    ) -- mon dd yyyy hh:mmAM (or PM) ) -- mm/dd/yyyy - 10/02/2008 ) -- yyyy.mm.dd -- 2008.10.02 ) -- dd/ ...

  6. 用 SQL 计算时间差值

    ;WITH res1 AS ( SELECT * FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY F2 ORDER BY F1) AS rn,F1,F2 F ...

  7. SQL Server DATEDIFF() 函数(SQL计算时间差)

    select  *   from   task_list  where 1=1 and    datediff(dd,carateTime,getdate()) =0      定义和用法 DATED ...

  8. golang 时间戳 时间格式化 获取当前时间 timestamp 计算时间差

    获取当前时间 func Now func Now() Time 1 Now returns the current local time. func (Time) UTC func (t Time) ...

  9. 【转载】c/c++在windows下获取时间和计算时间差的几种方法总结

    一.标准C和C++都可用 1.获取时间用time_t time( time_t * timer ),计算时间差使用double difftime( time_t timer1, time_t time ...

随机推荐

  1. 【Prism】MEF版Commanding

    引言 接下来的是Commanding Demo的改造. DelegateCommand    WPF本身提供了一个RoutedCommand,然而没什么卵用.在Prism框架中提供了个更人性化的ICo ...

  2. LeetCode OJ:Symmetric Tree(对称的树)

    Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For e ...

  3. xsl教程学习笔记

    一 . Hello world 尝试: Hello.xml: <?xml version="1.0" encoding="UTF-8"?> < ...

  4. hdu-1012-u Calculate e(水题)

    #include <iostream> using namespace std; int main() { ]; jiecheng[] = jiecheng[] = ; ; i<; ...

  5. IE9 placeholder 不兼容的解决

    坑爹的IE9-,真的是够够的了,不过公司不要求兼容这个玩意了,自己觉得兼容这个鬼还是挺有挑战性的,自己也碰到不少难题,一个个解决. css: .placeholderColor { color : # ...

  6. POJ - 3150 :Cellular Automaton(特殊的矩阵,降维优化)

    A cellular automaton is a collection of cells on a grid of specified shape that evolves through a nu ...

  7. 部署你的分布式调用链跟踪框架skywalking

    使用docker-compose 一键部署你的分布式调用链跟踪框架skywalking https://www.cnblogs.com/huangxincheng/p/9666930.html 一旦你 ...

  8. 每天一个linux命令(16):tail命令

    版权声明更新:2017-05-20博主:LuckyAlan联系:liuwenvip163@163.com声明:吃水不忘挖井人,转载请注明出处! 1 文章介绍 本文介绍了Linux下面的mv命令. 2. ...

  9. MMS(mongodb监控工具)

    今天好几个人问我如何查看mongodb的连接数,在mongo shell中执行: shard1:PRIMARY> db.serverStatus().connections { "cu ...

  10. (C#)Windows Shell 外壳编程系列2 - 解释,从“桌面”开始展开

    (本系列文章由柠檬的(lc_mtt)原创,转载请注明出处,谢谢-) 接上一篇:(C#)Windows Shell 外壳编程系列1 - 基础,浏览一个文件夹 让我们详细解释一下 Shell 编程中最基本 ...