时间加减:后边记得跟上时间类型如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. Linux5个数据段

        进程(执行的程序)会占用一定数量的内存,它或是用来存放从磁盘载入的程序代码,或是存放取自用户输入的数据等等.不过进程对这些内存的管理方式因内存用途不一而不尽相同,有些内存是事先静态分配和统一回 ...

  2. UVA 1594 Ducci Sequence(紫书习题5-2 简单模拟题)

    A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1, a2, · · · ...

  3. v-model 的修饰符

    1..trim 自动过滤输入内容最开始 和 最后的 空格,中间的会保留一个空格,多的会被过滤掉 2..lazy 一般情况下,在input的 v-model是一直在同步 输入的内容与显示的内容,不过再添 ...

  4. OpenCV学习笔记(二) cv::Mat

    部分内容转自:OpenCV Tuturial,ggicci 在OpenCV Tuturial中可查看Mat的初始化与打印方法. Mat本质上是由两个数据部分组成的类: 矩阵头(包含矩阵尺寸,存储方法, ...

  5. [转]Git for windows 下vim解决中文乱码的有关问题

    Git for windows 下vim解决中文乱码的问题 原文链接:Git for windows 下vim解决中文乱码的有关问题 1.右键打开Git bash: 2.cd ~ 3.vim .vim ...

  6. 51、如何提取android代码中的字符串为系统资源文件 (I18N)

    工具:android studio 步骤1:找到要转为资源文件的字符串并选中,同时按下option+enter,弹出菜单,我们选中extract string resource 步骤2:在弹窗中输入你 ...

  7. 基于web自动化测试框架的设计与开发(讲解演示PPT)

  8. 16进制转10进制 HDU-1720

    A+B Coming Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  9. Leetcode 652.寻找重复的子树

    寻找重复的子树 给定一棵二叉树,返回所有重复的子树.对于同一类的重复子树,你只需要返回其中任意一棵的根结点即可. 两棵树重复是指它们具有相同的结构以及相同的结点值. 下面是两个重复的子树: 因此,你需 ...

  10. RT-Thread学习之——静态线程和动态线程

    RT-Thread中支持静态和动态两种定义方式. 用线程来举例的话,rt_thread_init对应静态定义方式,rt_thread_create对应动态定义方式. 使用静态定义方式时,必须先定义静态 ...