zoukankan      html  css  js  c++  java
  • db2 timestampdiff

    DB2中使用方式

    计算两个时间戳记之间的时差:

    --秒的小数部分为单位 
    values timestampdiff(1,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 
    --秒为单位 
    values timestampdiff(2,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 
    --分为单位 
    values timestampdiff(4,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 
    --小时为单位 
    values timestampdiff(8,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 
    --天为单位 
    values timestampdiff(16,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 
    --周为单位 
    values timestampdiff(32,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 
    --月为单位 
    values timestampdiff(64,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 
    --季度为单位 
    values timestampdiff(128,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 
    --年为单位 
    values timestampdiff(256,char(current timestamp - timestamp('2010-01-01-00.00.00')));

    在调用timestampdiff转换的时候,两个日期是必须是日期格式,如果是varchar需要用timestamp来转换,调用timestampdiff转换后的结果是char(22)的类型

  • 相关阅读:
    git分支管理策略
    git解决冲突
    git分支创建和合并
    git连接远程库
    git删除文件
    git撤销修改
    4k测试网站
    Windows10通过TightVNC远程连接Ubuntu18.04
    robot报告合并输出
    python 传参中的*和**
  • 原文地址:https://www.cnblogs.com/JimShi/p/14345403.html
Copyright © 2011-2022 走看看