问题一:
strTimePoint := ' 08:00:00';
datBEGINDATE := to_date(to_char((sysdate - 1),'yyyy-mm-dd')||strTimePoint,'yyyy-mm-dd hh24:mi:Ss');
datENDDATE := to_date(to_char((sysdate),'yyyy-mm-dd')||strTimePoint,'yyyy-mm-dd hh24:mi:Ss');datMonthStart := to_date(to_char((sysdate-1),'yyyy')||'-'||to_char((sysdate-1),'mm')||'-01'||strTimePoint,'yyyy-mm-dd hh24:mi:Ss');
datYearStart := to_date(to_char((sysdate-1),'yyyy')||'-01-01'||strTimePoint,'yyyy-mm-dd hh24:mi:Ss');
我在跟踪调试的过程中,发现datBEGINDATE /datENDDATE 这个是有值的,datMonthStart /datYearStart 这两个却是NUll这是为什么.问题二:
从存储过程执行的结果来看datMonthStart /datYearStart 并没有取到它的具体时间08:00:00 而是00:00:00 .请问应该如何正确定义.
谢谢大家不吝赐教
strTimePoint := ' 08:00:00';
datBEGINDATE := to_date(to_char((sysdate - 1),'yyyy-mm-dd')||strTimePoint,'yyyy-mm-dd hh24:mi:Ss');
datENDDATE := to_date(to_char((sysdate),'yyyy-mm-dd')||strTimePoint,'yyyy-mm-dd hh24:mi:Ss');datMonthStart := to_date(to_char((sysdate-1),'yyyy')||'-'||to_char((sysdate-1),'mm')||'-01'||strTimePoint,'yyyy-mm-dd hh24:mi:Ss');
datYearStart := to_date(to_char((sysdate-1),'yyyy')||'-01-01'||strTimePoint,'yyyy-mm-dd hh24:mi:Ss');
我在跟踪调试的过程中,发现datBEGINDATE /datENDDATE 这个是有值的,datMonthStart /datYearStart 这两个却是NUll这是为什么.问题二:
从存储过程执行的结果来看datMonthStart /datYearStart 并没有取到它的具体时间08:00:00 而是00:00:00 .请问应该如何正确定义.
谢谢大家不吝赐教
trunc(sysdate-1,'mm')+1/3不就是你要的datMonthStart
datBEGINDATE := trunc(sysdate - 1,'dd')+8*60/1440;
datENDDATE := trunc(sysdate,'dd')+8*60/1440; datMonthStart := trunc(sysdate,'mm')+8*60/1440;
datYearStart := trunc(sysdate,'yyyy')+8*60/1440;
select trunc(sysdate, 'mm') + numtodsinterval('8', 'hour')
from dual;
我跟踪的时候,为何取不到datMonthStart 这个值呢.
datMonthStart := to_date(to_char((sysdate-1),'yyyy')||'-'||to_char((sysdate-1),'mm')||'-01'||strTimePoint,'yyyy-mm-dd hh24:mi:Ss'); 这样写有问题嘛?为何编译能过的?
http://hi.baidu.com/forhh/blog/item/a6a48326357e34128a82a1f2.html