时间加减:后边记得跟上时间类型如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. request_resource

    1.全局变量 resource结构体定义如下,指针parent.sibling.child用于构建树状结构. struct resource { resource_size_t start; reso ...

  2. Charles Babbage【查尔斯·巴贝奇】

    Charles Babbage When Babbage was working at Cambridge, a new idea occurred to him. 巴贝奇在剑桥工作的时候,脑海中有了 ...

  3. printf("\033[1;33m ***** \033[0m \n");

    printf("\033[1;33m Hello World. \033[0m \n"); 颜色如下: none = "\033[0m" black = &qu ...

  4. FZU 2082 过路费(树链剖分)

    树链剖分模板题. FZU炸了,等交上去AC了再贴代码.

  5. Android 完美解决bundle实现页面跳转并保留之前数据+传值

    1.前言 前言: 昨天碰到了一个问题,我想实现页面跳转,采用了Bundle之后,再回到原来的页面,发现数据也没有了, 而且一直报错,网上查找了很多资料,发现要用一个startActivityForRe ...

  6. MySQL之体系结构与存储实例

    定义数据库和实例 在数据库领域中有两个词很容易混淆,这就是“数据库”(database)和“实例”(instance).作为常见的数据库术语,这两个词的定义如下: 数据库:物理操作系统文件或其他形式文 ...

  7. 等比例适配所有屏幕---css3 rem用法

    1,rem的定义 rem(font size of the root element)是指相对于根元素的字体大小的单位.rem是一个相对单位.和em非常相似.em(font size of the e ...

  8. URL 传参中需要处理的特殊字符

    例如实际请求URL如下: http://www.douwansha.com/mdeditor?data=[{"address":null,"name":&quo ...

  9. c++11特性使用

    #include <list> #include <iostream> int main(){ list<int> lst; for(list<int> ...

  10. shell执行mysql的脚本(包括mysql执行shell脚本)

    在Shell中执行mysql的脚本,这里介绍比较容易使用的一种方法 首先写好sql的脚本,后缀为.sql,比如 sql_file.sql:内容如下 #这是SQL的脚本create table if n ...