时间加减:后边记得跟上时间类型如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. 理解 Objective-c "属性"

    理解 Objective-c "属性" @property 是OC中能够快速定义一个属性的关键字,如下我们定义一个属性. @property NSString *String; 这 ...

  2. VS2010官方下载地址

    http://download.microsoft.com/download/2/4/7/24733615-AA11-42E9-8883-E28CDCA88ED5/X16-42552VS2010Ult ...

  3. Roads in the North POJ - 2631

    Roads in the North POJ - 2631 Building and maintaining roads among communities in the far North is a ...

  4. HUD:3746-Cyclic Nacklace(补齐循环节)

    Cyclic Nacklace Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Pro ...

  5. Linux命令之---cat

    命令简介 cat命令的用途是连接文件或标准输入并打印.这个命令常用来显示文件内容,或者将几个文件连接起来显示,或者从标准输入读取内容并显示,它常与重定向符号配合使用. 命令格式 cat [选项] [文 ...

  6. Spring.Net初认识——竹子整理

    留个脚印,过两天总结. 看到知乎上有人对于DI|IOC 的解释,满不错,收藏下先 作者:OneNoodle链接:http://www.zhihu.com/question/23277575/answe ...

  7. install golang plugin in webstrom

    https://github.com/go-lang-plugin-org/go-lang-idea-plugin/wiki/Documentation

  8. C#+VisionPro连接相机获取图像的两种方式

    两种比较常用的方式. C#直接连接相机获取图像(GIGE) 在获取图像前,需要先创建一个相机对象,再使用这个相机对象的Acquire方法拍摄照片. ICogAcqFifo macqfifo;//定义相 ...

  9. 可实现一键分享到多个平台(微信,微博,qq空间,人人等)

    友推是一款是面向移动应用的SDK分享组件,提供给开发者集成使用.通过友推,开发者可以轻松集成社会化分享功能,同时创建及管理推荐好友使用您应用的推荐奖励活动,用户推荐好友安装使用您的应用即可获得推荐奖励 ...

  10. 2018安恒杯11月月赛 MISC

    题目放评论了 Numeric password 这次隐写没有按照套路出牌,很强. 记录一下 看来自主学习的能力很有待提高. 打开Numeric password.txt 中华文化博大精深,近日在教小外 ...