我还不是大学生,我正在努力进行一些日期计算。我的源代码中包含以下代码段:
LET dtRefDate = TODAY;
IF extend( CURRENT, hour to hour ) BETWEEN '06' AND '23' THEN LET
dtRefDate = TODAY+1;
END IF;
有人可以请我解释一下扩展功能做什么吗? CURRENT和TODAY有什么区别?我不理解与IBM官方文档的区别。 谢谢
答案 0 :(得分:2)
TODAY返回DATE值,CURRENT返回DATETIME(年份到分数(3))值。
EXTEND用于提取DATE或DATETIME值的各个部分。
看下面的例子:
> select CURRENT from table(set{1});
(expression)
2019-09-29 10:07:12.000
1 row(s) retrieved.
> select TODAY from table(set{1});
(expression)
09/29/2019
1 row(s) retrieved.
> select extend(TODAY,year to year) from table(set{1});
(expression)
2019
1 row(s) retrieved.
> select extend(TODAY,month to day) from table(set{1});
(expression)
09-29
1 row(s) retrieved.
> select extend(CURRENT,hour to minute) from table(set{1});
(expression)
10:08
1 row(s) retrieved.
>