`
hai0378
  • 浏览: 517059 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

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,oracle函数大全合集

    db2,oracle函数大全合集,db2,oracle函数大全合集,db2,oracle函数大全合集,db2,oracle函数大全合集

    DB2各类函数总汇

    DB2各类函数的分类总汇文档 1. 聚合函数 2. 类型转换函数 3. 数学函数 4. 字符串函数 5. 日期时间函数 6. XML 函数 7. 分区函数 8. 安全函数 9. 其他

    DB2 日期和时间的函数应用说明

    DB2中有关日期和时间的函数,及应用,比较老的文章了,需要的朋友可以参考下。

    DB2 日期数据库的sql语句

    自己总结的关于 db2数据库当前日期和前一天日期的sql语句

    PHP函数参考手册大全

    Date/Time 日期/时间函数 XXIII. DB++ Functions XXIV. dBase Functions XXV. DBM Functions [deprecated] XXVI. dbx Functions XXVII. Direct IO Functions XXVIII. Directory 目录函数 XXIX. DOM Functions XXX....

    db2日期的相关处理

    这是一个db2日期处理相关的word。有具体的例子和一些函数等。

    matlab 数字信号处理函数

    % 离散时间付利叶变换(第 z变换) % pfe2rfz - 在z域由部分分式展开为有理函数(第四章) % rf2pfez - 在z域由有理函数展开为部分分式(第四章) % 离散付利叶变换 % circevod - 实信号分解为循环偶分量和循环奇分量(第...

    以简单的方式捕获和存储DB2性能数据

    只需掌握一些SQL基本知识并了解开箱即用的DB2函数,就可以开始使用该框架。下列步骤展示了如何成功构建一个性能数据库。本文档中的示例是使用DB2V10.1forLinux,UNIX,andWindows创建的。由于DB29.7中提

    程序员的SQL金典 学会MSSQLServer、MYSQL、Oracle、DB2

    2.配合大量真实案例,学了就能用,在短时间内成为数据库 开发高手 3.高度提取不同数据库的共同点,仔细分析不同点,并给出 解决方案,同时学会MSSQLServer、MYSQL、Oracle、DB2 数据库不再是梦 4.国内第一本讲解开窗...

    PHP5 完整官方 中文教程

    Date/Time — Date/Time 日期/时间函数 DB++ — DB++ Functions dba — Database (dbm-style) Abstraction Layer Functions dBase — dBase Functions DBM — DBM Functions [deprecated] dbx — dbx Functions ...

    PHP5中文参考手册

    Date/Time — Date/Time 日期/时间函数 DB++ — DB++ Functions dba — Database (dbm-style) Abstraction Layer Functions dBase — dBase Functions DBM — DBM Functions [deprecated] dbx — dbx Functions ...

    程序员的SQL金典.rar

     5.3 日期时间函数  5.3.1 日期、时间、日期时间与时间戳  5.3.2 主流数据库系统中日期时间类型的表示方式  5.3.3 取得当前日期时间  5.3.4 日期增减  5.3.5 计算日期差额  5.3.6 计算一个日期是星期几  ...

    程序员的SQL金典6-8

     5.3 日期时间函数  5.3.1 日期、时间、日期时间与时间戳  5.3.2 主流数据库系统中日期时间类型的表示方式  5.3.3 取得当前日期时间  5.3.4 日期增减  5.3.5 计算日期差额  5.3.6 计算一个日期是星期几  ...

    程序员的SQL金典7-8

     5.3 日期时间函数  5.3.1 日期、时间、日期时间与时间戳  5.3.2 主流数据库系统中日期时间类型的表示方式  5.3.3 取得当前日期时间  5.3.4 日期增减  5.3.5 计算日期差额  5.3.6 计算一个日期是星期几  ...

    程序员的SQL金典4-8

     5.3 日期时间函数  5.3.1 日期、时间、日期时间与时间戳  5.3.2 主流数据库系统中日期时间类型的表示方式  5.3.3 取得当前日期时间  5.3.4 日期增减  5.3.5 计算日期差额  5.3.6 计算一个日期是星期几  ...

    程序员的SQL金典3-8

     5.3 日期时间函数  5.3.1 日期、时间、日期时间与时间戳  5.3.2 主流数据库系统中日期时间类型的表示方式  5.3.3 取得当前日期时间  5.3.4 日期增减  5.3.5 计算日期差额  5.3.6 计算一个日期是星期几  ...

    中文版PHP使用手册

    Date/Time 日期/时间函数 XXIII. DB++ Functions XXIV. dBase Functions XXV. DBM Functions [deprecated] XXVI. dbx Functions XXVII. Direct IO Functions XXVIII. Directory 目录函数 XXIX. DOM Functions XXX....

    经典收藏最全php5.0查询手册

    Date/Time 日期/时间函数 XXIII. DB++ Functions XXIV. dBase Functions XXV. DBM Functions [deprecated] XXVI. dbx Functions XXVII. Direct IO Functions XXVIII. Directory 目录函数 XXIX. DOM Functions XXX....

    php手册PHP5研究室编无乱码版本chm

    Date/Time 日期/时间函数 XXIII. DB++ Functions XXIV. dBase Functions XXV. DBM Functions [deprecated] XXVI. dbx Functions XXVII. Direct IO Functions XXVIII. Directory 目录函数 XXIX. DOM ...

Global site tag (gtag.js) - Google Analytics