DB2时间函数大全(转)

摘要:
资料来源:http://database.51cto.com/art/201011/232578.htm1--获取当前日期:23selectcurrentdatefromsysibm。系统虚拟1;4值当前日期;56--从sysibm获取当前日期7selectcurrenttime。系统虚拟1;8值当前时间;9--获取当前时间戳1
原文出处:http://database.51cto.com/art/201011/232578.htm

1
--获取当前日期: 2 3 select current date from sysibm.sysdummy1; 4 values current date; 5 6 --获取当前日期 7 select current time from sysibm.sysdummy1; 8 values current time; 9 --获取当前时间戳 10 select current timestamp from sysibm.sysdummy1; 11 values current timestamp; 12 13 --要使当前时间或当前时间戳记调整到 GMT/CUT,则把当前的时间或时间戳记减去当前时区寄存器: 14 15 values current time -current timezone; 16 values current timestamp -current timezone; 17 18 --获取当前年份 19 20 values year(current timestamp); 21 22 --获取当前月 23 values month(current timestamp); 24 25 --获取当前日 26 values day(current timestamp); 27 28 --获取当前时 29 values hour(current timestamp); 30 31 --获取分钟 32 values minute(current timestamp); 33 34 --获取秒 35 values second(current timestamp); 36 37 --获取毫秒 38 values microsecond(current timestamp); 39 40 --从时间戳记单独抽取出日期和时间 41 42 values date(current timestamp); 43 values VARCHAR_FORMAT(current TIMESTAMP,'yyyy-mm-dd'); 44 values char(current date); 45 values time(current timestamp); 46 47 --执行日期和时间的计算 48 49 values current date+1 year; 50 values current date+3 years+2 months +15 days; 51 values current time +5 hours -3 minutes +10 seconds; 52 53 --计算两个日期之间的天数 54 55 values days(current date)- days(date('2010-02-20')); 56 57 --时间和日期换成字符串 58 59 values char(current date); 60 values char(current time); 61 62 --要将字符串转换成日期或时间值 63 64 values timestamp('2010-03-09-22.43.00.000000'); 65 values timestamp('2010-03-09 22:44:36'); 66 values date('2010-03-09'); 67 values date('03/09/2010'); 68 values time('22:45:27'); 69 values time('22.45.27'); 70 71 --计算两个时间戳记之间的时差: 72 73 --秒的小数部分为单位 74 values timestampdiff(1,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 75 --秒为单位 76 values timestampdiff(2,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 77 --分为单位 78 values timestampdiff(4,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 79 --小时为单位 80 values timestampdiff(8,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 81 --天为单位 82 values timestampdiff(16,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 83 --周为单位 84 values timestampdiff(32,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 85 --月为单位 86 values timestampdiff(64,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 87 --季度为单位 88 values timestampdiff(128,char(current timestamp - timestamp('2010-01-01-00.00.00'))); 89 --年为单位 90 values timestampdiff(256,char(current timestamp - timestamp('2010-01-01-00.00.00')));

免责声明:文章转载自《DB2时间函数大全(转)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇pcm数据格式存储格式修改sublime Text 的默认配置文件位置下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

CronExpression Cron表达式校验Util 工具类

CronExpression.java 标签(空格分隔): Java import java.io.Serializable; import java.text.ParseException; import java.util.Calendar; import java.util.Date; import java.util.HashMap; impo...

Spring Boot + Spring Cloud 实现权限管理系统 (Spring Security 版本 )

技术背景 到目前为止,我们使用的权限认证框架是 Shiro,虽然 Shiro 也足够好用并且简单,但对于 Spring 官方主推的安全框架 Spring Security,用户群也是甚大的,所以我们这里把当前的代码切分出一个 shiro-cloud 分支,作为 Shiro + Spring Cloud 技术的分支代码,dev 和 master 分支将替换为...

基于datax的数据同步平台

一、需求 由于公司各个部门对业务数据的需求,比如进行数据分析、报表展示等等,且公司没有相应的系统、数据仓库满足这些需求,最原始的办法就是把数据提取出来生成excel表发给各个部门,这个功能已经由脚本转成了平台,交给了DBA使用,而有些数据分析部门,则需要运维把生产库的数据同步到他们自己的库,并且需要对数据进行脱敏,比如客户的身份证号、手机号等等,且数据来...

[Linux环境编程] Linux系统命令“ls -R”的实现

Linux系统命令“ls -R”的实现   一、基本概念1、“ls -R”的意义   递归处理,将指定目录下的所有文件及子目录一并显示。   例: ls   -R   ./testdir1/     ./testdir1/:    test1.c   test1.txt   test2.txt   testdir2     ./testdir1/testd...

ICMP timestamp 请求响应漏洞

ICMP timestamp请求响应漏洞   解决方案: * 在您的防火墙上过滤外来的ICMP timestamp(类型13)报文以及外出的ICMP timestamp回复报文。   google之,于是动手解决:      具体解决方式就是禁用ICMP timestamp-request,编辑etc/sysconfig/iptables文件,在防火墙规则...

HTML5表单之input 类型- Date Pickers(日期选择器)

HTML5 拥有多个可供选取日期和时间的新输入类型: date:选取日、月、年 month:选取月、年 week:选取周和年 time:选取时间(小时和分钟) datetime-local:选取时间、日、月、年(本地时间) datetime:选取时间、日、月、年(在有些浏览器内失效,选用datetime-local) 例1:date <input...