select EHAUDITDATE, EHID
into dtEhauDate, nEhid
from DIP_EXCEL_HEADER@DBL_DCT_DIP DIP_EXCEL_HEADER
where OTID = nSourceID
and HSID = 4
and Etid = 1301
and EHFREETLDATE = ntemp;EHAUDITDATE列中的日期是 年月日 小时 分钟 秒而抽取出来的 dtEhauDate只是 年月日 是用TO_DATE()吗?》
into dtEhauDate, nEhid
from DIP_EXCEL_HEADER@DBL_DCT_DIP DIP_EXCEL_HEADER
where OTID = nSourceID
and HSID = 4
and Etid = 1301
and EHFREETLDATE = ntemp;EHAUDITDATE列中的日期是 年月日 小时 分钟 秒而抽取出来的 dtEhauDate只是 年月日 是用TO_DATE()吗?》
写修改下系统的时间格式
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'在查询下看看
select EHAUDITDATE, EHID
into dtEhauDate, nEhid
from DIP_EXCEL_HEADER@DBL_DCT_DIP DIP_EXCEL_HEADER
where OTID = nSourceID
and HSID = 4
and Etid = 1301
and EHFREETLDATE = ntemp;
如果是date型
可以试试to_char(EHAUDITDATE,'yyyy-mm-dd hh24:mi:ss')
这个是什么类型的
也要定义为长日期类型的
请问长时间类型是怎么定义?我是DATE。。数据库也是DATE
to_char(dtEhauDate,'yyyy-mm-dd hh24:mi:ss')
date类型的用to_char()转一下就能看到了
into dtEhauDate, nEhid
from DIP_EXCEL_HEADER@DBL_DCT_DIP DIP_EXCEL_HEADER
where OTID = nSourceID
and HSID = 4
and Etid = 1301
and EHFREETLDATE = ntemp;
SZdate:=to_char(dtEhauDate,'yyyy-mm-dd hh24:mi:ss') ;
dtEhauDate:=to_date(SZdate,'yyyy-mm-dd hh24:mi:ss') ;
这么转换 还是没有分时秒!!!!郁闷
dtEhauDate varchar2(40);
begin
select to_char(hiredate,'yyyy-mm-dd hh24:mi:ss')
into dtEhauDate
from emp
where rownum<2;
dbms_output.put_line(dtEhauDate);
end;
在示例数据库EMP上运行结果正确!
date类型的字段直接比较就行。。
要不就把你最终要比较的字段用to_char()转化一下。
难道我要转化成CHAR才能比较出时分秒?我直接用DATE的话 时分秒会被忽略
11:59:43 scott@TUNGKONG> select to_date('2009-11-26 11:10:10','yyyy-mm-dd hh24:mi:ss')-to_date('2009-11-26 10:10:10','yyyy-mm-dd hh24:mi:ss') from dual;TO_DATE('2009-11-2611:10:10','YYYY-MM-DDHH24:MI:SS')-TO_DATE('2009-11-2610:10:10','YYYY-MM-DDHH24:MI
----------------------------------------------------------------------------------------------------
.041666667已用时间: 00: 00: 00.00它们怎么会相等呢。。
直接转化为秒操作,计算出天,小时和分
这样OK?
应该可以满足你的要求