DB2关于时间的一些函数

2006年9月25日 | 作者: 挨踢开发一点通 | 浏览: 624

字体 -

得到当前时间的年份、月份、天、小时等等:

YEAR (current timestamp) MONTH (current timestamp) DAY (current timestamp) HOUR (current timestamp) MINUTE (current timestamp) SECOND (current timestamp) MICROSECOND (current timestamp)

分别得到当时的日期和时间

DATE (current timestamp) TIME (current timestamp)

关于时间的一些计算:

current date + 1 YEAR current date + 3 YEARS + 2 MONTHS + 15 DAYS current time + 5 HOURS - 3 MINUTES + 10 SECONDS

计算两个日期之间有多少天:

days (current date) - days (date(’1999-10-22′))

得到去除毫秒的当前时间:

CURRENT TIMESTAMP - MICROSECOND (current timestamp) MICROSECONDS

将时间转换成字符串:

char(current date) char(current time) char(current date + 12 hours)

将字符串转换成时间:

TIMESTAMP (’2002-10-20-12.00.00.000000′) TIMESTAMP (’2002-10-20 12:00:00′) DATE (’2002-10-20′) DATE (’10/20/2002′) TIME (’12:00:00′) TIME (’12.00.00′)

分享博文至:

没有评论

  1. 没有评论

发表评论