时间加减:后边记得跟上时间类型如day、HOUR
 
TIMESTAMP ( TIMESTAMP(DEF_TIME)+1 day)+18 HOUR
 
 
 
DB2时间函数是我们最常见的函数之一,下面就为您介绍一些DB2时间函数,供您参考,希望可以让您对DB2时间函数有更多的了解。
 
--获取当前日期:  
select current date from sysibm.sysdummy1;  
values current date; 
 
--获取当前日期  
select current time from sysibm.sysdummy1;  
values current time;  
--获取当前时间戳  
select current timestamp from sysibm.sysdummy1;  
values current timestamp;  
 
--要使当前时间或当前时间戳记调整到GMT/CUT,则把当前的时间或时间戳记减去当前时区寄存器: 
 
values current time -current timezone;  
values current timestamp -current timezone;  
 
--获取当前年份  
values year(current timestamp); 
 
--获取当前月  
values month(current timestamp); 
 
--获取当前日  
values day(current timestamp); 
 
--获取当前时  
values hour(current timestamp); 
 
--获取分钟  
values minute(current timestamp); 
 
--获取秒  
values second(current timestamp); 
 
--获取毫秒  
values microsecond(current timestamp);  
 
--从时间戳记单独抽取出日期和时间  
values date(current timestamp);  
values VARCHAR_FORMAT(current TIMESTAMP,'yyyy-mm-dd');  
values char(current date);  
values time(current timestamp);  
 
--执行日期和时间的计算  
values current date+1 year;     
values current date+3 years+2 months +15 days;  
values current time +5 hours -3 minutes +10 seconds;  
 
--计算两个日期之间的天数  
values days(current date)- days(date('2010-02-20'));  
 
--时间和日期换成字符串  
values char(current date);  
values char(current time);  
 
--要将字符串转换成日期或时间值  
values timestamp('2010-03-09-22.43.00.000000');  
values timestamp('2010-03-09 22:44:36');  
values date('2010-03-09');  
values date('03/09/2010');  
values time('22:45:27');  
values time('22.45.27');  
 
--计算两个时间戳记之间的时差: 
 
--秒的小数部分为单位  
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')));

DB2时间函数 实现 时间加减的更多相关文章

  1. Delphi日期函数、日期加减

    Delphi里有现成的函数可以实现日期加减,是在DateUtils单元里的. function IncYear(const AValue: TDateTime; const ANumberOfYear ...

  2. mysql时间函数和时间操作

    补 原文链接:http://blog.csdn.net/yuxiayiji/article/details/7480785 select timediff('23:40:00', ' 18:30:00 ...

  3. sqlite 时间函数及时间处理

    SQLite分页显示:Select * From news order by id desc Limit 10 Offset 10这篇文章是根据 SQLite 官方 WIKI 里的内容翻译,如果有什么 ...

  4. Oracle计算时间函数(对时间的加减numtodsinterval、numtoyminterval) (转)

    原文来自:http://blog.itpub.net/756652/viewspace-697256/ 11g interval分区,按天分区,需要用到函数numtodsinterval.   cre ...

  5. 对时间进行操作 加减 XXX天

    date:要操作的时间目标 days: 要加减的天数时间 addDate: function(date, days) { if (date == '') { return '' }; if (days ...

  6. [转帖]PG的时间函数使用整理如下

    PG的时间函数使用整理如下 https://blog.csdn.net/dahuzix/article/details/48576945 1.获取系统时间函数 -- :: -- :: -- :: 2. ...

  7. Java 中,如何对日期进行加减操作

    今天在做项目时,遇到了对时间的加减进行操作的需求,根据传入的日期字符串,操作参数("+","-"),加数(要操作的天数),对日期进行加减操作,经查询资料,自己写 ...

  8. js实现购买数量加减效果

    写在前面:当我们需要在多个页面都有操作数量的需求时的一种解决方案 结构: js代码: <script type="text/javascript"> function ...

  9. PHP 日期 加减 月数,天数,周数,小时,分,秒等等

    实就是strtotime 这个内置函数 //PHP 日期 加减 周 date("Y-m-d",strtotime("2013-11-12 +1 week")) ...

随机推荐

  1. Flask初学者:session操作

    cookie:是一种保存数据的格式,也可以看成是保存数据的一个“盒子”,服务器返回cookie给浏览器(由服务器产生),由浏览器保存在本地,下次再访问此服务器时浏览器就会自动将此cookie一起发送给 ...

  2. Essential C++ 3.1 节的代码练习——指针方式

    // // PointerToValue.cpp // Working // // Created by Hawkins, Dakota Y on 6/3/16. // Copyright 2016 ...

  3. [原]sencha touch之panel和tabpanel

    最近在弄senchatouch的项目,所以边学习边开发,边记录,直接记录下test code如下: Panel: Ext.application({ name:'itKingApp', launch: ...

  4. CodeForces 781D Axel and Marston in Bitland DP

    题意: 有一个\(n\)个点\(m\)条边的无向图,边有两种类型,分别用\(0\)和\(1\)标识 因此图中的任意一条路径都对应一个\(01\)字符串 定义一个无限长的字符串\(s\): 开始令\(s ...

  5. “帮你APP”团队冲刺5

    1.整个项目预期的任务量 (任务量 = 所有工作的预期时间)和 目前已经花的时间 (所有记录的 ‘已经花费的时间’),还剩余的时间(所有工作的 ‘剩余时间’) : 所有工作的预期时间:88h 目前已经 ...

  6. easyui-combogrid匹配查询

    用到easyui-combogrid,数据比较少的情况,可以一页就显示完毕,然后直接下拉选择.但是对于数据量比较大的情况,一页显示全部显然不合适,好在从easyui-combogrid的数据加载方式可 ...

  7. 设计模式之第3章-模板方法模式(Java实现)

    设计模式之第3章-模板方法模式(Java实现) "那个,上次由于我老婆要给我做饭,所以就没有说完就走掉了...这个那个".这次和以前一样,先来开场福利(工厂方法模式已被作者踹下场) ...

  8. Selenium中如何运行 auto.exe 文件

    Runtime exe = Runtime.getRuntime(); try{ String str = "D:\\Auto上传文件\\photo.exe"; exe.exec( ...

  9. LuffyCity-MySQL综合练习50实例

    1.请创建如下表,并添加相应约束: 2.自行构造测试数据: 新建数据库 创建表 构造测试数据 #Step1-创建数据库LuffyCity_MySQL; #CREATE DATABASE LuffyCi ...

  10. [oldboy-django][2深入django]django目录说明 + 路由系统

    django project目录说明 project - app01 -- admin.py #django自带后台管理 -- apps.py #app01配置文件 -- models.py #编写类 ...