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)的类型

  • 相关阅读:
    HDOJ 1207 汉诺塔II
    [转]写代码的小女孩
    POJ Subway tree systems
    HDOJ 3555 Bomb (数位DP)
    POJ 1636 Prison rearrangement (DP)
    POJ 1015 Jury Compromise (DP)
    UVA 10003
    UVA 103 Stacking Boxes
    HDOJ 3530 Subsequence
    第三百六十二、三天 how can I 坚持
  • 原文地址:https://www.cnblogs.com/JimShi/p/14345403.html
Copyright © 2011-2022 走看看